jQuery noConflict

jQuery noConflict()


In jQuery $ is used as an alias(shortcut) for jQuery. Other javascript libraries might also use $ variable
The method noConflict () is used to resolves multiple jQuery version or another library conflicts problem.

If you use another javascript library which also use $ as a function or variable name. Just call $.noConflict() to return control of $ back to the other library.

Examples:

jQuery.noConflict();
(function( $ ) {
  $(function() {
    // More code using $ as alias to jQuery
  });
})(jQuery);
 
// Other code using $ as an alias to the other library
<script src="other_lib.js"></script>
<script src="jquery.js"></script>
<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {
  // Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
</script>
date2019-04-02 21:16:30 From:www.jquerypluginhub.com Author:JPH
Related Tags:
Comments

Leave a Reply

Your email address will not be published. Required fields are marked *