不点击就触发?
我想运行滚动功能:
$("body").scrollTo({ top: "0px", left: "2200px" }, 800);
...没有任何手动(单击)触发器,所以基本上它应该在加载时运行。是否可以?
I'd like to run a scroll function:
$("body").scrollTo({ top: "0px", left: "2200px" }, 800);
...without any manual (click) trigger, so basically it should run on load. is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
呃?不太确定你在问什么。您可以通过对相关元素调用
.trigger('click')
以编程方式触发单击,而无需用户实际单击鼠标。如果您只想立即发生滚动,请将其包装在
$(document).ready(function() { ... });
Eh? Not quite sure what you're asking. You can programatically trigger a click without the user having to physically click his mouse by calling
.trigger('click')
on the element in question.If you just want to the scroll to occur immediately, wrap it in
$(document).ready(function() { ... });
尝试添加 .load()
jsfiddle 演示
Try adding .load()
jsfiddle Demo