2017-05-08 118 views
0

我對此錯誤進行了分析不知道什麼是問題,它超級簡單,但我無法找到爲什麼函數沒有調用,而是它顯示引用錯誤未捕獲的ReferenceError:函數未在HTMLInputElement.onclick中定義,但功能可用

ProjectQueue.php:1 Uncaught ReferenceError: QuoteUnsuccessful is not defined 
    at HTMLInputElement.onclick (ProjectQueue.php:1) 

我的功能在下面給出,它是在單獨的JS文件中,我正確引用。

function QuoteUnsuccessful(projectQueueId){ 

     console.log("QuoteSuccesfull make upcomming "+projectQueueId); 
} 

而HTML

<input type="button" value="successful" class="btn btn-danger " onclick="QuoteUnsuccessful(1)"> 
+0

正確檢查外部js文件的位置。 –

回答

0

檢查您的js文件輸入標籤之前插入HTML。

<script> 
    function QuoteUnsuccessful(projectQueueId){  
    console.log("QuoteSuccesfull make upcomming "+projectQueueId); 
    } 
</script>  
<input type="button" value="successful" class="btn btn-danger" onclick="QuoteUnsuccessful(1)"> 

但我建議你使用addEventListener insted onclick attr。

相關問題