This example describes the jquery class selector usage. Share to everyone for your reference. The specific analysis is as follows:
Class selects all the elements that have the specified class name.
Example:
Copy Code code as follows:
The above code selects all elements of the class named Mydiv.
Note: There is a little (.) in front of the mydiv.
Instance code:
Copy Code code as follows:
<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" content= "http://www.jb51.net/"/>
<title> Cloud-dwelling community </title>
<style type= "Text/css" >
div{
height:150px;
width:150px;
Background-color:green;
margin-top:10px;
}
</style>
<script type= "Text/javascript" src= "Mytest/jquery/jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("button"). Click (function () {
$ (". Mydiv"). Hide ();
})
})
</script>
<body>
<div class= "Mydiv" ></div>
<div class= "Anotherdiv" ></div>
<button> Click to hide div elements </button>
</body>
The code above can hide the div element with the class name Mydiv.
I hope this article will help you with your jquery programming.