未捕获引用错误:$未定义(PHP中的JavaScript/HTML)

未捕获引用错误:$未定义(PHP中的JavaScript/HTML),javascript,php,html,forms,Javascript,Php,Html,Forms,我网站上的脚本导致了一些意外错误:uncaughtreferenceerror:$未定义 它应该重写enter函数,作为站点表单输入中的一个选项卡,而不是提交该表单 <script type="text/javascript"> $('input').keypress(function(e) { if (e.which == 13) { <--! says error is here within the $ symbol --> $(this).n

我网站上的脚本导致了一些意外错误:
uncaughtreferenceerror:$未定义
它应该重写enter函数,作为站点表单输入中的一个选项卡,而不是提交该表单

<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>

$('input')。按键(功能(e){
如果(e.which==13){
$(this.next('input').focus();
e、 预防默认值();
}
});

这可能是因为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>

$('input')。按键(功能(e){
如果(e.which==13){
$(this.next('input').focus();
e、 预防默认值();
}
});

这意味着您在使用jQuery之前没有包含它。您需要在运行此代码之前加载jQuery。Thx伙计们,很抱歉重新发布此。。我认为这和其他类似的问题是不同的