触发()和triggerHandler()与“点击”,在页面加载时触发厚盒
我试图在页面加载的链接上触发单击事件。我目前正在这里处理此代码 http://jsfiddle.net/QPPbA/
$(document).ready(function(){
$('#trigger-me').trigger('click');
});
<a href="http://www.stackoverflow.com" target="_blank" id="trigger-me">trigger hidden</a>
但它不起作用。我在这里缺少什么?
编辑
我想在页面加载时触发一个厚盒,我得到了一些代码,但它只显示黑色“色调”..所以我想我会像这样触发它,但这种方式也不起作用..有什么建议吗?
im trying to trigger a click event on a link on the page load. im currently working on this code here http://jsfiddle.net/QPPbA/
$(document).ready(function(){
$('#trigger-me').trigger('click');
});
<a href="http://www.stackoverflow.com" target="_blank" id="trigger-me">trigger hidden</a>
but it does not work. what im i missing here?
EDIT
I would like to trigger a thickbox on page load, i got some code but it only shows the black "tint".. so i thougth i would trigger it like this but this way does not work either.. any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它没有点击事件...
更新: jsfiddle
It hasn't got a click event...
update: jsfiddle
当您使用 JavaScript 触发事件时,不会调用浏览器对该事件的默认操作。在这种情况下,当您触发链接上的
click
事件时,它不会导致导航。如果您想将访问者重定向到另一个页面,可以使用
window.location
:When you trigger an event with JavaScript, the browser's default action for that event isn't invoked. In this case, it won't cause a navigation when you trigger the
click
event on a link.If you want to redirect the visitor to another page, you can use
window.location
:尝试这个作为替代:
Try this as alternative: