This example describes the usage of the height () method in jquery. Share to everyone for your reference. The specific analysis is as follows:
This method can get or set the height value of the matching element, the default unit is PX.
Grammatical structure One:
Copy Code code as follows:
Returns the current height of the first matching element without parameters.
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 () {
Alert ($ ("div"). Height ());
})
</script>
<body>
<div></div>
</body>
Grammatical structure two:
Copy Code code as follows:
$ (selector). Height (val)
with parameters is to set the height of all matching elements , the default unit is PX, of course, you can also use other units such as EM or percent, and so on.
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 () {
$ ("div"). Height ("200px")
})
})
</script>
<body>
<div></div>
<button> Click to view Effect </button>
</body>
I hope this article will help you with your jquery programming.