Recent Posts

jQuery Version Check: live() Vs. On()

jQuery Version Check: live() Vs. On()

12:34 31 January in Compatibility, JavaScript, jQuery, Thomas' Toolkit

Recently I started work on my own jQuery plugins.  I do love that jQuery.  But, as I was working, I came to see the difference between on() and live().

I’m reading that live() is depreciated, so in order to make my plugin a bit more universal, I wrote a function to detect the jQuery version being used, and act accordingly.  Here it is:

function useOn(){
		var jRequired = '1.7.1'.split('.');
		var jInstalled = jQuery.fn.jquery.split('.');
		var on = true;
		for(x in jInstalled){
			if(parseInt(jInstalled[x]) < parseInt(jRequired[x]) && on==true){
				on = false;	
		return on;

If the jQuery version is 1.7.1 or higher, this function will return true. If lower, it will return false. I call the function when I'm getting ready to set click functions on some of my objects.

I couldn't find anything like it will poking around Google, so hopefully someone else finds this helpful.

No Comments

Post A Comment

%d bloggers like this: