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.
我在一个调用函数的网站中看到了一个 jquery 函数调用,例如
var exampleFunction = function() { console.log ( " running " ); } $(exampleFunction);
它被称为 $(exampleFunction); 用这个可以吗?虽然它工作,但我还没有看到这种类型的编码风格。
是的$(function)缩写$(document).ready(function)。soexampleFunction会在加载 dom 时调用
$(function)
$(document).ready(function)
exampleFunction
见http://api.jquery.com/ready/