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(); });
Comments
Post a Comment