Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of hiding elements in javascript

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "the method of hiding elements in javascript". The editor shows you the operation process through the actual case. The method of operation is simple, fast and practical. I hope this article "the method of hiding elements in javascript" can help you solve the problem.

Javascript hide elements: 1, use the "element object .style.display =" none "statement; 2, use the" element object .style.style = "hidden" statement; 3, use the "element object .style.opacity = 0" statement.

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

Several methods of hiding elements in javascript

First kind

# myBtn {width: 300px; height: 150px; background-color: rgb (16130150); color: coral; font-size: 35px;} Hidden element points I'm surprised! Var btn = document.getElementById ("myBtn") btn.addEventListener ('click', function (event) {document.getElementById ("myBtn"). Style.display = "none";})

The second kind

Hidden element # myBtn {width: 300px; height: 150px; background-color: rgb (220,140,228); color: coral; font-size: 35px;} I'm surprised! Var btn = document.getElementById ("myBtn") btn.addEventListener ('click', function (event) {document.getElementById ("myBtn"). Style.visibility = "hidden";})

The third kind

Hidden element # myBtn {width: 300px; height: 150px; background-color: rgb (192,231,128); color: coral; font-size: 35px;} I'm surprised! Var btn = document.getElementById ("myBtn") btn.addEventListener ('click', function (event) {document.getElementById ("myBtn"). Style.opacity = 0;})

The fourth kind

Hidden element # myBtn {width: 300px; height: 150px; background-color: rgb (156,97,121); color: coral; font-size: 35px;} I'm surprised! Var btn = document.getElementById ("myBtn") btn.addEventListener ('click', function (event) {$("# myBtn"). Hide ();}) this is the end of the introduction on "how to hide elements in javascript". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report