Five tips for jQuery developers

Source: Internet
Author: User

1. Disable right-click menu
Copy codeThe Code is as follows:
$ (Document). ready (function (){
$ (Document). bind ("contextmenu", function (e ){
Return false;
});
});

2. flashing the font
Copy codeThe Code is as follows:
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
Copy codeThe Code is as follows:
$ (Function (){
// Document is ready do something
});

4. Check the browser
Copy codeThe Code is as follows:
// 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 existing elements
Copy codeThe Code is as follows:
If ($ ("# someDiv"). length ){
// Yes it does, do something
}

Related Article

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.