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

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -