hello friends, I need a little help.. here is my code: 1st - <a href="http://mysite.com/search" id="search">search</a> I want to make hyperlink using 2nd method but its not working please let me know what I'm doing wrong. the 1st is another link in my template. I want to make a link using 2nd method at another place. 2nd <a href="#" onclick="window.location.href=$("#search").attr('href')">search</a>
The problem is that you used double quotes inside double quotes so your onclick command is actually just "window.location.href=$(". This should work: <a href="#" onclick="location.href=$('#search').attr('href')">search</a> or you can cancel the inner double quotes: <a href="#" onclick="location.href=$(\"#search\").attr('href')">search</a>