jQuery.noConflict()

5 Responses

  1. Asho says:

    what to use if we need to use another javascript library like mootools??? is this same function noConflict() works???

    • Anonymous says:

      you can use both together! Since MooTools is prototype-based and jQuery is not, jQuery and MooTools may be used together on the same page.

      //no conflict jquery
      jQuery.noConflict();
      //jquery stuff
      (function($) {
      $(‘p’).css(‘color’,’#ff0000′);
      })(jQuery);

      //moo stuff
      window.addEvent(‘domready’,function() {
      $$(‘p’).setStyle(‘border’,’1px solid #fc0′);
      });

      jQuery is namespaced so the $ function is free for MooTools to take hold of. The jQuery code passes jQuery to itself and then we call the argument $, thus jQuery is contained, so to speak.

      Obviously including two libraries within the same page is resource-consuming but if it’s acceptable to the project and allows you to implement plugins from each library quickly, this may be a great option for you.

      hope this helps.. 🙂

  2. Asho says:

    what to use if we need to use another javascript library like mootools??? is this same function noConflict() works???

    • itzurkarthi says:

      you can use both together! Since MooTools is prototype-based and jQuery is not, jQuery and MooTools may be used together on the same page.

      //no conflict jquery
      jQuery.noConflict();
      //jquery stuff
      (function($) {
      $(‘p’).css(‘color’,’#ff0000′);
      })(jQuery);

      //moo stuff
      window.addEvent(‘domready’,function() {
      $$(‘p’).setStyle(‘border’,’1px solid #fc0′);
      });

      jQuery is namespaced so the $ function is free for MooTools to take hold of. The jQuery code passes jQuery to itself and then we call the argument $, thus jQuery is contained, so to speak.

      Obviously including two libraries within the same page is resource-consuming but if it’s acceptable to the project and allows you to implement plugins from each library quickly, this may be a great option for you.

      hope this helps.. 🙂

  3. Asho says:

    what to use if we need to use another javascript library like mootools??? is this same function noConflict() works???

Leave a Reply

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