javascript - detect jquery version use on or live -


i writing plugin can used in website dont know exact version of jquery , getting few issues .on() method.

to fix have simple still getting errors in jquery 1.4.2.

var $myelements = $('.elements'),     myfunction = function(e){         console.log('here');         e.preventdefault();      }  if (typeof jquery != 'undefined') {     if(jquery.fn.jquery < 1.4){         $myelements.live('click', myfunction);     } else {         $(document).on('click', $myelements, myfunction);     } } 

based on previous answer, can too:

;(function($) {   if(!$.fn.on) {     $.fn.on = $.fn.live;   } }(window.jquery || window.zepto)); 

then can use on in rest of code.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -