5 useful jquery tricks every web developer should know


jquery-logo

Hello developers.  We really find jquery  a good framework and find out really good tricks which every web developer should know.

Here is the list:

1. Disable right-click menu:

1
2
3
4
5
$(document).ready(function(){
    $(document).bind("contextmenu",function(e){
        return false;
    });
});

.

2. Making your content Flash (Blink):

1
2
3
4
5
6
7
8
jQuery.fn.flash = function( color, duration )
{
    var current = this.css( 'color' );
    this.animate( { color: 'rgb(' + color + ')' }, duration / 2 );
    this.animate( { color: current }, duration / 2 );
}
 
$( '#someid' ).flash( '255,0,0', 1000 );

.

3. Document ready alternative:

1
2
3
$(function(){
	//document is ready do something
});

.

4. Detect Browser:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Safari
if( $.browser.safari )
{
//do something
}
 
//Above IE6
if ($.browser.msie && $.browser.version > 6 )
{
//do something
}
 
// IE6 and below
if ($.browser.msie && $.browser.version <= 6 )  { //do something } // Firefox 2 and above if ($.browser.mozilla && $.browser.version >= "1.8" )
{
//do something
}

.

5. Check for Element existence:

1
2
3
if ($("#someDiv").length) {
    //yes it does ,do something
}

Thats it!!
Cheers!

Recently Published

»

9 Social Media and Marketing Tools Recommended for a Business

A business is set up to have a profit by delivering a product or a ...

»

Why hand-coding is always preferable over website builders

There is long debate as to why hand-coding is preferable over website ...

»

8 Reasons Your Site Should be Using Progressive Web Apps

Google has been driving at full speed since 2015 to help developers, ...

»

Tips to Handle Negative Feedback for Your Mobile App

Feedback from users for your mobile app is as essential as its ...

»

Why is Link Building So Important? Read this to understand

Getting a high ranking on search engine results is important to the ...

»

Productivity Tips for Web Developers for Efficient Time Management

The world is full of distractions. Whether you are a work-from-home, ...

»

The Importance of a Good Domain Name

The right domain name can genuinely make or break a business – ...

»

Cloud Strategy of Oracle: Working or Not?

Though Oracle considered cloud strategy as gibberish long before, it ...

»

Some Excellent SEO Tools for Boosting SEO Rankings like Never Before

You could be having a really great-looking website and the niftiest ...