Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想运行一个滚动功能:
$("body").scrollTo({ top: "0px", left: "2200px" }, 800);
...没有任何手动(点击)触发器,所以基本上它应该在加载时运行。是否可以?
诶?不太清楚你在问什么。.trigger('click')您可以通过调用相关元素以编程方式触发单击,而无需用户物理单击鼠标。
.trigger('click')
如果您只想滚动立即发生,请将其包装在$(document).ready(function() { ... });
$(document).ready(function() { ... });
尝试添加 .load()
$("body").load().scrollTo({ top: "0px", left: "2200px" }, 800);
jsfiddle 演示