gpt4 book ai didi

javascript - jquery : $(document). 准备好只接受匿名处理程序吗?

转载 作者:行者123 更新时间:2023-12-01 02:03:51 24 4
gpt4 key购买 nike

是否可以使用定义的函数作为 jQuery 的 $(document).ready() 的处理程序而不是匿名函数?

我做了很多实验,但没有成功。其中之一在这里:http://pastebin.com/XHKPc879 .

最佳答案

是的,这是可能的:

function pancakes() { /* Do interesting things */ }
$(document).ready(pancakes);

你的pastebin的问题:

$(document).ready(test());

当你说test()时,你正在调用test函数,只需去掉括号就可以了。

关于javascript - jquery : $(document). 准备好只接受匿名处理程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8109968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com