Jquery .click() doesn't fire for <a> tag
$(document).ready(function () {
$(":button").click(function () {
$(this).next('a').click();
});
});
HTML
<div style="text-align:center">
<input type="button" value="More" class="button">
<a style="display:none" href="/Resource/PhysicianMaterials">aaa</a>
</div>
In this cod开发者_如何学Goe .click()
doesn't fire for tag, can anyone say what is the problem? Thanks
The click
event is firing, however, a click
does not go to the URL when you're talking about an anchor (that happens at the browser/native event level, it's not JavaScript triggered).
Instead you need to do that navigation yourself, like this:
$(document).ready(function () {
$(":button").click(function () {
window.location = $(this).next('a').attr('href');
});
});
精彩评论