包含在格式正确的html中时,Javascript文件不起作用

包含在格式正确的html中时,Javascript文件不起作用,javascript,php,html,Javascript,Php,Html,我的js文件的标题中包含了jquery,格式正确,但它似乎不起作用 下面是需要js文件的storepage.php文件的标题 把钥匙拿过来 这是javascript文件的开头 function tester() { console.log("Checking document status..."); } console.log("Checking document status..."); $(document).ready(function() { 控制台中没有显示任何内容

我的js文件的标题中包含了jquery,格式正确,但它似乎不起作用

下面是需要js文件的storepage.php文件的标题


把钥匙拿过来
这是javascript文件的开头

function tester() {
    console.log("Checking document status...");
}


console.log("Checking document status...");
$(document).ready(function() {

控制台中没有显示任何内容,因此我现在有点不知所措。

您应该在
文档中调用函数。ready()
方法,以便在加载文档后运行该函数:

function tester() {
    console.log("Checking document status...")
}

$(document).ready(function(){
  tester()
});

您应该在
文档中调用函数。ready()
方法使其在加载文档后运行:

function tester() {
    console.log("Checking document status...")
}

$(document).ready(function(){
  tester()
});

为什么你的控制台上什么也没显示

  • 因为当文档准备就绪时,您没有调用
    tester()
    函数
  • 您的文档就绪语法错误
  • 您需要的是,像这样编写真正的文档准备语法,并调用
    tester()
    函数

    $(document).ready(function(){
      tester();
      console.log('testing'); //call the console log manually when the document ready.
    });
    

    为什么你的控制台上什么也没显示

  • 因为当文档准备就绪时,您没有调用
    tester()
    函数
  • 您的文档就绪语法错误
  • 您需要的是,像这样编写真正的文档准备语法,并调用
    tester()
    函数

    $(document).ready(function(){
      tester();
      console.log('testing'); //call the console log manually when the document ready.
    });
    

    控制台上有错误吗?控制台上有错误吗?