2015-12-02 114 views
-3

我在我網站上的這個腳本引起了一些意外錯誤:Uncaught ReferenceError: $ is not defined 它應該重寫輸入的功能以充當網站表單上的輸入內的選項卡提交該表格。

<script type="text/javascript"> 
$('input').keypress(function(e) { 
    if (e.which == 13) { 
    <--! says error is here within the $ symbol --> 
    $(this).next('input').focus(); 
    e.preventDefault(); 
    } 
}); 
</script> 
+0

這意味着你使用它之前,沒有包括jQuery的 – Tushar

+0

您需要在運行此代碼之前加載jQuery的。 – tarleb

+0

Thx夥計我很抱歉重新發布此..我雖然從其他類似的問題 –

回答

3

這可能是因爲jQuery沒有定義。 (我假設你正在使用juery)。

嘗試包括jQuery的第一:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
<script type="text/javascript"> 
$('input').keypress(function(e) { 
    if (e.which == 13) { 
    <--! says error is here within the $ symbol --> 
    $(this).next('input').focus(); 
    e.preventDefault(); 
    } 
}); 
</script> 
相關問題