我们是否应该在外部js中包装jquery代码$(document).ready(function(){

Jit*_*yas 1 css xhtml jquery

当我们编写内联javascript时,我们将代码保留在里面

$(document).ready(function(){
   // Your code here
 });
Run Code Online (Sandbox Code Playgroud)

如果我想粘贴

code // Your code here
Run Code Online (Sandbox Code Playgroud)

在外部.js文件然后我应该保持代码在这里

$(document).ready(function(){
       // Your code here
     });
Run Code Online (Sandbox Code Playgroud)

或者我们可以没有这个

// Your code here
Run Code Online (Sandbox Code Playgroud)

sil*_*ent 5

只有在使用此页面的DOM时,才必须将代码保留在就绪函数中.当DOM完全加载时执行此函数.