I'm new to jQuery and I'm getting an error in a web page of mine as follows: "Uncaught TypeError: Cannot read property 'noConflict' of undefined"
I'm using jQuery in my page and it was suggested to me that I should use
var $j = jQuery.noConflict();
Is there a way I can unsure I don't receive the undefined error when setting my $j variable?
Thanks in advance.
I'm new to jQuery and I'm getting an error in a web page of mine as follows: "Uncaught TypeError: Cannot read property 'noConflict' of undefined"
I'm using jQuery in my page and it was suggested to me that I should use
var $j = jQuery.noConflict();
Is there a way I can unsure I don't receive the undefined error when setting my $j variable?
Thanks in advance.
Share Improve this question edited May 9, 2016 at 15:50 Mike Cluck 32.5k13 gold badges83 silver badges94 bronze badges asked May 9, 2016 at 15:47 RedQueriesRedQueries 1591 gold badge1 silver badge8 bronze badges 3-
1
That error has occurred, jquery is not loaded in your html. Add this in your header area
<sript src='https://code.jquery./jquery-2.2.3.min.js'>
– 0xdw Commented May 9, 2016 at 15:48 - This mean that jQuery is not loaded in the web page, are you loading it? – Gumma Mocciaro Commented May 9, 2016 at 15:49
-
2
Something is weird here, because if
jQuery
were simply not defined, the error would beUncaught ReferenceError: jQuery is not defined
. The error which FRed gets apperas like thejQuery
variable is declared but its value isundefined
. – CherryDT Commented May 9, 2016 at 15:50
2 Answers
Reset to default 3I Faced the same problem.
Please Use the code like this.
Click Here(function($) {
$('#dev').click(function(){
alert();/*You can add any code here */
});
})(jQuery);
If you want to Use .noconflict ment I will edit this.
Assuming you are currently not loaded jQuery into your html page. So your html looks like this after jQuery is loaded.
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- load jQuery in header area -->
<script src="https://code.jquery./jquery-2.2.3.min.js"></script>
</head>
<body>
<!-- content -->
<script>
var $j = jQuery.noConflict();
console.log($j); // function (a,b){return new n.fn.init(a,b)}
</script>
</body>
</html>