Home > Web Front-end > JS Tutorial > How to use css to set height in jquery

How to use css to set height in jquery

青灯夜游
Release: 2023-01-05 16:13:07
Original
3092 people have browsed it

Jquery method of operating css to set the height: first use "$()" to get the HTML element node, and then use the css() method to set the height by operating the css style; the specific syntax is "$("selector") .css("height","height value");".

How to use css to set height in jquery

The operating environment of this tutorial: windows7 system, jquery3.0.0 version, Dell G3 computer.

jquery operates css to set height

In jquery, you can use the css() method to operate css to set height

css() method to set or Returns one or more style properties of the selected element. The basic syntax is as follows:

$("选择器").css("height","高度值");
Copy after login

Code example:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style type="">
    	div{
    		border:1px solid red;
    	}
    </style>
    <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
    <script>
      $(function() {
        $(".dome").css("height", "200px");
      });
    </script>
  </head>
  <body>
  	<div>测试文本</div>
  	<div class="dome">测试文本</div>
    <div>测试文本</div>
    
  </body>
</html>
Copy after login

Rendering:

How to use css to set height in jquery

For more programming-related knowledge, please visit : Programming Video! !

The above is the detailed content of How to use css to set height in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template