Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery不使用Jade_Javascript_Jquery_Pug - Fatal编程技术网

Javascript JQuery不使用Jade

Javascript JQuery不使用Jade,javascript,jquery,pug,Javascript,Jquery,Pug,我有一些JQuery在我的Jade文件中,用于我的expressweb应用程序,但似乎没有调用任何东西。以下是jade文件的内容: extends layout block content p Landing page #info Info area block foot a(href="https://localhost:8888/logout", title="logout") Logout !!!5 html head title #{ti

我有一些JQuery在我的Jade文件中,用于我的expressweb应用程序,但似乎没有调用任何东西。以下是jade文件的内容:

extends layout
block content
    p Landing page
    #info Info area
block foot
    a(href="https://localhost:8888/logout", title="logout") Logout
!!!5
html
    head
        title #{title}
        link(rel='stylesheet', href='/stylesheets/style.css')
        script(type='text/javascript', src="http://code.jquery.com/jquery-1.9.1.min.js")
        script(type='text/javascript', src="/idle-timer.js")
        script(type='text/javascript').
            $(document).ready(function() {
                $(document).idleTimer(10000);
                $(document).on("idle.idleTimer", function(){
                    console.log("alert");
                });

                $(#info).click(function(){
                    $(this).hide();
                });
            });
    body
        header
            h1 Web App Sample
        .container
            .main-content
                block content
            .sidebar
                block sidebar
        footer
            block foot
以下是布局文件:

extends layout
block content
    p Landing page
    #info Info area
block foot
    a(href="https://localhost:8888/logout", title="logout") Logout
!!!5
html
    head
        title #{title}
        link(rel='stylesheet', href='/stylesheets/style.css')
        script(type='text/javascript', src="http://code.jquery.com/jquery-1.9.1.min.js")
        script(type='text/javascript', src="/idle-timer.js")
        script(type='text/javascript').
            $(document).ready(function() {
                $(document).idleTimer(10000);
                $(document).on("idle.idleTimer", function(){
                    console.log("alert");
                });

                $(#info).click(function(){
                    $(this).hide();
                });
            });
    body
        header
            h1 Web App Sample
        .container
            .main-content
                block content
            .sidebar
                block sidebar
        footer
            block foot

有人知道问题出在哪里吗?可能是缩进?

在我的手机上很难看到,但您是否将脚本代码缩进如下:

html
    head
        script(src='jsfile')
        script
            $(document).ready
    body #same level as head!
        header

在我的手机上很难看到,但您是否将脚本代码缩进如下:

html
    head
        script(src='jsfile')
        script
            $(document).ready
    body #same level as head!
        header

script(type='text/javascript')。
-行末尾的这个点有什么作用吗?您可以更轻松地将JS添加到外部文件中,并像对
idle timer.JS
那样调用它。点显然是必需的,因为当我不添加它时,控制台中会出现此警告,“隐式文本仅用于
脚本
样式
不推荐使用。使用
脚本。
样式。
。“如果得到正确的html,请尝试在源代码中检查生成的代码。此外,您没有将QOUTIONS添加到
$(“#信息”)
啊,是的,谢谢。另外,doc.ready()如果我将代码放在外部js文件中而不是放在头部,或者该部分应该放在头部,而只是将函数放在外部?我可以通过单击按钮获得一个外部javascript函数来执行,但我的文档中仍然没有任何内容。ready正在工作。
script(type='text/javascript').
-行末尾的这个点有什么作用吗?您可以更轻松地将JS添加到外部文件中,然后像调用
idle timer.JS
一样调用它。这个点显然是必需的,因为当我不添加它时,控制台中会出现此警告,”不推荐使用仅用于
脚本
样式
的隐式文本。使用
脚本。
样式。
。“如果得到正确的html,请尝试在源代码中检查生成的代码。此外,您没有将QOUTIONS添加到
$(“#信息”)
啊,是的,谢谢。另外,doc.ready()如果我将代码放在外部js文件中而不是放在头部,或者该部分应该放在头部而只是外部的函数中?我可以通过单击按钮获得外部javascript函数来执行,但我的文档中仍然没有任何内容。ready正在工作。