I have a simple link click simulation that I want to do using jQuery. From what I read, this should work, but the code below doesn’t work. Nothing happens if I do the same thing as a part of some other event or something either. Thoughts?
<script type="text/javascript">
$(function() {
$("#lnk_0").click();
});
</script>
<a id="lnk_0" href="http://mydomain.com/mypage.html">link</a>
See
click():The important thing to note is that it does not duplicate clicking the link. It only triggers associated events. If you want to change location:
but even that is only an approximation as it doesn’t cater for handlers stopping event propagation.