Skilful act jQuery tips and tricks

jQuery tips

jQuery is a JavaScript library which is simple, light-weight, open source, cross browser and simplifies animations, event handling, and developing Ajax-based web applications and promotes rapid application development.

Here are few jQuery tips:

Check Element Exists

if ($("#element").length)
{ 
...
}

Check Element Is Visible

if($("#element").is(":visible") == "true")
{ 
...
}

Disable Right Mouse Click

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

Current Mouse Coordinates

$(document).ready(function() {
    $().mousemove(function(e)
    {
    $('#mouseDiv ').html("X Axis = " + e.pageX + " and Y Axis = " + e.pageY);
    });
});
<DIV id=mouseDiv></DIV>

Determine Browser

$(document).ready(function() {
// If the browser type is Mozilla Firefox
if ($.browser.mozilla && $.browser.version >= "1.8" ){ 
// some code
}
// If the browser type is Opera
if( $.browser.opera)
{
// some code
}
// If the web browser type is Safari
if( $.browser.safari )
{
// some code
}
// If the web browser type is Chrome
if( $.browser.chrome)
{
// some code
}
// If the web browser type is Internet Explorer
if ($.browser.msie && $.browser.version <= 6 )
{
// some code
}
//If the web browser type is Internet Explorer 6 and above
if ($.browser.msie && $.browser.version > 6)
{
// some code
}
});

Chaining Feature

$(element).removeClass('Class1').addClass('Class2');

 

Based on United States, Jacob Frazier is a skilled JavaScript developer with over 8 years of experience. He is passionate about change and trying new things, both professionally and personally. He loves startups and is extremely proactive.

You may like:  Clear form fields with exception in jQuery

2 thoughts on “Skilful act jQuery tips and tricks”

  1. Wonderful post! We will be linking to this particularly great post on our site. Keep up the great writing.

Leave a Reply

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