JQuery Tips

Tips-And-Tricks



Disabling Right Mouse Click:

$(document).ready(function(){
$(document).bind(“contextmenu”,function(e){
return false;
});
});

—————

Determine User’s Browser:

$(document).ready(function() {

if( $.browser.safari ){
alert(“safari browser.”)
}

if( $.browser.chrome){
alert(“chrome browser.”)
}

if ($.browser.mozilla ){ 
alert(“mozilla browser.”)
}

if ($.browser.msie ){
alert(“msie browser.”)
}

if( $.browser.opera){
alert(“opera browser.”)
}

});

—————

jQuery Cloning
jQuery supports cloning – you can use the clone() method to create a clone of any DOM element in your web page. Here is an example:

var cloneObject = $(‘#divObject‘).clone();

—————

Methods Chaining:

$(‘sampleElement’).removeClass(‘thisClass’).addClass(‘addClass’);

—————

Lazy Loading
Lazy loading is a handy feature in jQuery that enables you to load only the content that is needed. 

To use this, incorporate the jquery.lazyload.js script file:

<script src=”jquery.js” type=”text/javascript”></script>
<script src=”jquery.dimensions.js” type=”text/javascript”></script>
<script src=”jquery.lazyload.js” type=”text/javascript”></script>

Now, you can use the lazyload() method as below:

$(“imageOne”).lazyload();



Leave a Reply

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