Home > Article > Web Front-end > How to set height in jquery css
The method for setting the height of jquery css is the height method. This method can return or set the height of the matching element. The syntax for setting the height is such as "$(selector).height(length)". The parameter length specifies the height of the element. high.
The operating environment of this article: Windows7 system, jquery3.2.1&&css3 version, DELL G3 computer
jQuery CSS operation - height() Method
height() method returns or sets the height of the matching element.
Return height
Return the height of the first matching element.
If no parameters are set for this method, the height of the matching element in pixels is returned.
Syntax
$(selector).height()
Set the height
Set the height of all matching elements.
Syntax
$(selector).height(length)
Parameters
length
Optional. Specifies the height of the element.
If no length unit is specified, the default px unit is used.
Example:
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ $("p").height(50); }); }); </script> </head> <body> <p style="background-color:yellow">This is a paragraph.</p> <button class="btn1">改变高度</button> </body> </html>
Effect screenshot:
Recommended learning: "jquery video tutorial"
The above is the detailed content of How to set height in jquery css. For more information, please follow other related articles on the PHP Chinese website!