JQuery不使用Jade

JQuery不使用Jade

问题描述:

我的Express Web应用程序的Jade文件中有一些JQuery,但似乎没有任何东西被调用。这里的内容玉文件:JQuery不使用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 

任何人都可以看到的问题可能是什么?也许缩进?

+1

'脚本(类型=“文/ JavaScript的”)' - 这是否点在该行的末尾做什么?可能会更容易将您的JS添加到外部文件中,并像调用'idle-timer.js'一样调用它。 – Andy

+0

这个圆点显然是必需的,因为当我不添加它时,我在控制台中得到这个警告,“implicit textOnly for'script'和'style'已被弃用,请使用'script.'或'style.'。 – gjw80

+2

尝试在源代码中检查生成的代码,如果您获得正确的html。此外,你错过了添加qoutations''('#信息')' – Drew

很难看到我的手机,但你缩进你的脚本代码,如:。

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