Get the App
SLTechnology News&Howtos  ›  Development  › 

How javascript sets the height of an element

Shulou Source: shulou.com Published: 2022-06-03 13:02:39 09月11日 Update

Editor to share with you how javascript sets the height of elements. I hope you will get something after reading this article. Let's discuss it together.

Setting method: 1, use "document.getElementById (" id value ")" statement to get the specified element object; 2, use "element object .style.height =" value "or" element object .style.cssText = "height: value" statement.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Javascript sets the height (height) of the element

1. Get the element object

Document.getElementById ("id value")

2. Set the height (height) of the element

Use object .style. Attribute name = "value"

Use object .style.cssText = "attribute name: value"

Example

Default width of text box

Text box height set to 50px

Text box height is set to 100px document.getElementById ("text1") .style.height = "50px"; document.getElementById ("text2") .style.cssText = "height:100px"

Effect picture:

After reading this article, I believe you have a certain understanding of "how to set the height of elements in javascript". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Elements objects height text attributes articles statements finished width effects renderings tutorials methods more environment computers knowledge examples systems industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei NVidia Shulou Tech Info Redmi MariaDB