jqueryexample.com jQuery .noConflict() method - jqueryexample.com

jQuery .noConflict() method by jqueryexample

If we are referring any other script files (MooTools, prototype.js,YUI ) along with jQuery you may get conflicts in the namespace between the two libraries.
Note: you need to use is jQuery’s .noConflict() method like this jQuery.noConflict(); before you write any jQuery code. jQuery will return $() to it’s previous owner .So we need to use jQuery() instead of $() function.
<html>
<head>
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>
jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
</script>
</head>
<body></body>
</html>

Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment