Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
20
rated 0 times [  21] [ 1]  / answers: 1 / hits: 25041  / 9 Years ago, wed, december 2, 2015, 12:00:00

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>

More From » php

 Answers
5

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>

[#64196] Monday, November 30, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jennie

Total Points: 593
Total Questions: 102
Total Answers: 106

Location: Federated States of Micronesia
Member since Fri, Sep 16, 2022
2 Years ago
;