-1

This script I have on my site is causing some unexpected error: Uncaught ReferenceError: $ is not defined it should rewrite function of enter to act as a tab within the inputs on site form instead of submitting that form.

<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>
bruntime
  • 371
  • 2
  • 13
Lucián Blažek
  • 49
  • 1
  • 1
  • 7

1 Answers1

11

Thats probably because jQuery isn't defined. (I'm assuming you are using juery).

Try including jQuery first:

<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>
Nelson Owalo
  • 2,324
  • 18
  • 37