<a href="www.google.com">
<span>Some text</span>
<button class="triggeranchorclick"/>
</a>
Using jQuery, how could you cause a click of t开发者_如何学Che button to trigger the link to be clicked - i.e. the user ends up getting redirected to Google.
I don't understand, why do u wanna do this, 'cause you're wrapping the <button>
with an <a>
tag. so you don't need to write extra bit of code for doing this
Anyway here's my technique,
$(function () {
$('.triggeranchorclick').bind('click', function (e) {
window.location.href = $(this).parent('a').attr('href');
});
});
精彩评论