2016-11-03 80 views
0

我做了一個非常簡單的列表與點擊第一個li標籤顯示觸發一個js的功能,但它與錯誤抱怨:未捕獲的ReferenceError:getTodayRequest沒有定義(...)

Uncaught ReferenceError: getTodayRequest is not defined(…) 

這裏代碼

<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org"> 
<head> 
<script> 
     function getTodayRequest(){ 
      console.log("here is today"); 
      alert("here is today"); 
     } 

</script> 
</head> 
<body> 
    <div th:fragment="statistic_menu"> 
     <div class="panel"> 
      <div class="panel-body"> 
       <div class="col-md-6 col-sm-12"> 
        <h3 class="animated fadeInLeft">Statistic</h3> 

        <ul class="nav navbar-nav"> 
         <li onclick="getTodayRequest()">Today</li> 

        </ul> 
       </div> 
      </div>      
     </div> 
    </div> 

</body> 
</html> 
+0

一切正確無誤 – cna327

+0

@DineshSubhashPatil,爲什麼需要jQuery? –

回答

0

沒有什麼是錯的,它工作正常

<!DOCTYPE html> 
 
<html xmlns:th="http://www.thymeleaf.org"> 
 
<head> 
 
<script> 
 
     function getTodayRequest(){ 
 
      console.log("here is today"); 
 
      alert("here is today"); 
 
     } 
 

 
</script> 
 
</head> 
 
<body> 
 
    <div th:fragment="statistic_menu"> 
 
     <div class="panel"> 
 
      <div class="panel-body"> 
 
       <div class="col-md-6 col-sm-12"> 
 
        <h3 class="animated fadeInLeft">Statistic</h3> 
 

 
        <ul class="nav navbar-nav"> 
 
         <li onclick="getTodayRequest()">Today</li> 
 

 
        </ul> 
 
       </div> 
 
      </div>      
 
     </div> 
 
    </div> 
 

 
</body> 
 
</html>

相關問題