<script type="text/javascript"> $(function() { $("#lnk_0").click(); }); </script> <a id="lnk_0" href="http://mydomain.com/mypage.html">link</a>
click()
Triggers the click event of each matched element. Causes all of the functions that have been bound to that click event to be executed.
Triggers the click event of each matched element.
Causes all of the functions that have been bound to that click event to be executed.
重要的是要注意的是,它不会重复点击链接.它只触发相关事件.如果要更改位置:
var link = $("#link_0"); link.click(); window.location.href = link.attr("href");
但即使这只是一个近似值,因为它不适合处理程序阻止事件传播.