我在触发页面加载链接上的点击时给出了一个简单的示例,但是它不起作用。我不想浏览那个href,我只想让触发器对其他我将要处理的东西起作用,这是头代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"> </script>
<script type="text/javascript">
$(document).ready(function() {
setTimeout(function() {
$("a#test").trigger('click');
},1000);
});
</script>
和身体代码
<a href="http://www.yahoo.com" id="test">click</a>
你可以试试这个吗
$(document).ready(function() {
$( "#test" ).on( "click", function() {
alert('Clicked');
window.location.href = $( this ).attr('href'); //automatic redirection from the link href
console.log('clicked');
});
setTimeout(function() {
$("#test").trigger('click');
},1000);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句