Five tips each jQuery developer needs to know

Source: Internet
Author: User

JQuery is a good framework. The following summarizes five tips that every website developer should know:

1. Disable right-click menu

$ (Document). ready (function (){
$ (Document). bind ("contextmenu", function (e ){
Return false;
});
});

2. flashing the font

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 ('2017, 255, 1000 );

3. Prepare a document replacement solution

$ (Function (){
// Document is ready do something
});

4. Check the browser

// Safari
If ($. browser. safari)
{
// Do something
}

// Above IE6
If ($. browser. msie & amp; $. browser. version & gt; 6)
{
// Do something
}

// IE6 and below
If ($. browser. msie & amp; $. browser. version & lt; = 6) {// do something} // Firefox 2 and above if ($. browser. mozilla & amp; $. browser. version & gt; = "1.8 ")
{
// Do something
}

5. Check for existing elements

If ($ ("# someDiv"). length ){
// Yes it does, do something
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.