开发者

Trigger without click?

开发者 https://www.devze.com 2023-02-28 14:39 出处:网络
I\'d like to run a scroll function: $(\"body\").scrollTo({ top: \"0px\", left: \"2200px\" }, 800); ...without any manual (click) tr开发者_开发知识库igger, so basically it should run on load. is it

I'd like to run a scroll function:

$("body").scrollTo({ top: "0px", left: "2200px" }, 800);

...without any manual (click) tr开发者_开发知识库igger, so basically it should run on load. is it possible?


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() { ... });


Try adding .load()

$("body").load().scrollTo({ top: "0px", left: "2200px" }, 800);

jsfiddle Demo

0

精彩评论

暂无评论...
验证码 换一张
取 消