2017-05-08 116 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。

相关问题