-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>
3
  • This means you haven't included jQuery before using it Commented Dec 2, 2015 at 10:25
  • You need to load jQuery before running this code. Commented Dec 2, 2015 at 10:26
  • Thx guys im sorry for reposting this .. i though its different problem from other similar ones Commented Dec 2, 2015 at 10:31

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.