2015-12-02 155 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> 
相关问题