【发布时间】:2016-03-06 13:11:42
【问题描述】:
我网站上的这个脚本导致了一些意外错误:Uncaught ReferenceError: $ is not defined
它应该重写 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>
【问题讨论】:
-
这意味着你在使用之前没有包含 jQuery
-
你需要在运行这段代码之前加载jQuery。
-
谢谢大家,我很抱歉重新发布这个..我虽然它与其他类似的问题不同
标签: javascript php html forms