The Hide () method usage instance in jquery _jquery

Source: Internet
Author: User

This example describes the use of the Hide () method in jquery. Share to everyone for your reference. The specific analysis is as follows:

This method can hide the matching elements.

Use of the Hide () method:
If this method does not have a time limit on the hidden effect, then the matching element is instantly hidden. For example:

Copy Code code as follows:
$ ("div"). Hide ()

The above code can instantly hide all div elements.
If the method has a time limit for the hidden effect, then the matching element will be hidden in a more elegant form within the qualifying event. For example:
Copy Code code as follows:
$ ("div"). Hide (2000)

The code above can hide all div elements in 2000 milliseconds (2 seconds).
This method can also trigger a callback function after the shadowing completes. For example:
Copy Code code as follows:
$ ("div"). Hide (2000,function () {alert ("I Hide It")});

Instance code:

Copy Code code as follows:

<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" content= "http://www.jb51.net/"/>
<title>hide () function-cloud-dwelling community </title>
<style type= "Text/css" >
div{
Color:blue;
Background-color:green;
width:100px;
height:100px;
margin-top:10px;
}
</style>
<script type= "Text/javascript" src= "Mytest/jquery/jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#first"). Click (function () {
$ (". a"). Hide ();
})
$ ("#second"). Click (function () {
$ (". Second"). Hide (2000,function () {alert ("I Hide It")});
})
})
</script>
<body>
<div class= "a" ></div>
<div class= "Second" ></div>
<button id= "A" > Instant hide </button>
<button id= "Second" > Elegant hide </button>
</body>

The code above can trigger the callback function after the hide is complete, and a prompt box pops up.

I hope this article will help you with your jquery programming.

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.