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:
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:
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.