I changed the jQuery version from 3.6.0 to 3.6.3 and I get an error when I use the load function.
I have the below code
$(document).ready(function() {
$('.nav, #menu').click(function(e) {
e.preventDefault();
$('#content').load($(this).attr('href'));
});
});
and I get the below error
TypeError: Cannot read properties of undefined (reading ‘indexOf’)
at jQuery.fn.load (jquery-3.6.3.js:10473:13)
at HTMLUListElement. (dashboard.php:64:19)
at HTMLUListElement.dispatch (jquery-3.6.3.js:5494:27)
at elemData.handle (jquery-3.6.3.js:5298:28)
If I change the jQuery version to 3.6.0 the error disappears. If I change the version of jQuery to 3.6.1, 3.6.2, or 3.6.3 I get the above error.
Is anything wrong with my code?
I tried different versions of jquery and I get the same error.
2
Answers
The element are links as you can see below
Without seeing your html its a guess, but you probably fire the event through elements that arent links. Try changing it to:
Or, to be super sure: