Learn Noclict () usage in jQuery

jQuery uses $ symbols as JQuery’s shorthand

JavaScript framework includes: Mootools, Backbone, Sammy, Cappuccino, Knockout, JavaScriptmvc, GoogleWebtoolkit , GoogleClosure, EMBER, BATMAN, and EXTJS, etc.

Some of these frames also use the symbol as a shorthand

If two different frames are used, the same shorthand symbol can be used, which may cause scripts To this end, jQuery provides a noconflict () method

to release the control of the $ identifier

In this way, other scripts can be used

$. Noconflict ();

   Replacement 
Using jQuery full name, replacing itself $

jQuery (Document) .ready (function () {jQuery (“Button “) .click (function () {jQuery (” p “). Text (” jQuery is still working! “);});});

   Creating a short-write 
You can create your own shorthand

NOCONFLICT () can return to jQuery reference

stores it into a variable, then use this variable Instead of $

VARJQ = $ .noconflict (); jq (docuument) .ready (“Button”). Click (“” “). Text (” jQuery is still working! “); });});

Parameter transmission
 can be used as variables, passed to Ready method   In this way, the $ symbol can be used in the function, outside the function, can not use $ 

$. Noclict (); jQuery (document) .ready (Function). ) {$ (“Button”). Click (“p”). Text (“jQuery is still working!”);});});

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment