Luc*_*žek -3 html javascript php forms
我在我的网站上的这个脚本导致了一些意外错误: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>
Run Code Online (Sandbox Code Playgroud)
这可能是因为没有定义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>
Run Code Online (Sandbox Code Playgroud)