Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

javascript - $(document).ready简写($(document).ready shorthand)

Is the following shorthand for $(document).ready ?(以下是$(document).ready简写吗?)

(function($){ //some code })(jQuery); I see this pattern used a lot, but I'm unable to find any reference to it.(我看到这种模式使用了很多,但我找不到任何引用。) If it is shorthand for $(document).ready() , is there any particular reason it might not work?(如果它是$(document).ready()简写,是否有任何特殊原因可能无效?) In my tests it seems to always fire before the ready event.(在我的测试中,似乎总是在准备好的事件之前开火。)   ask by Mark Brown translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The shorthand is:(简写是:)

$(function() { // Code here });

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...