I have some Javascript code:
function addRow(tableID, rowId) {
var table = document.getElementById(tableID);
var rowPosition = document.getElementById(rowID).rowIndex;
//etc.
}
But this throws a Javascript error
"Uncaught ReferenceError: rowID is not defined"
Though looking on Firebug, I can see that the functions receives a correct row identifier, but once the code reaches the second line inside the function the parameter rowID
seems unknown.
Can anyone help?
The $ is not defined ReferenceError usually arises when jQuery is not loaded and JavaScript is not recognizing the $ symbol. To solve this error, first, use jQuery CDN link inside the head section or download the jQuery file and use the jQuery file link inside the head section.
The Javascript ReferenceError occurs when referencing a variable that does not exist or has not yet been initialized in the current scope.
Answer: Execute Code after jQuery Library has Loaded The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading.
JavaScript is case-sensitive. You've used rowId
as the argument name (small "d") while inside the function you have rowID
(capital "D"). Change the argument to rowID
to fix the issue.
You're passing the parameter rowId
, but referencing it rowID
. Variable names are case sensitive, they both need to be the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With