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

python - Installing PyDev in eclipse is failed -

PHP OOP-based login system -

c# - Nested Internal Class with Readonly Hashtable throws Null ref exception.. on assignment -