javascript - js How to add href + text onclick -


i need pass (using javascript) text inside span href

<div class='tablecell'><span>information</span></div> <div class='tablecell'><span>contact</span></div> <div class='tablecell'><span>about</span></div>   

for example when click link must example.com/tag/about/

the simplest way:

$( "span" ).click(function() {  var link = 'http://yousite.com/tag/'+ $(this).text().replace(/ /, "-")+"/";  window.location.href= link.tolowercase();  }); 

demo

http://codepen.io/tuga/pen/ynyypm


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -