Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement show and hide operations in DIV

Shulou Source: shulou.com Published: 2022-06-02 18:23:06 09月16日 Update

This article will explain in detail how to achieve show and hide operations in DIV. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

I. DIV Show / hide

1. Set div to show or hide

Document.getElementById ("div1") .style.display = "none"; / / DIV hides document.getElementById ("div2") .style.display= "; / / DIV display

Of course, it can also be displayed directly as follows:

Div1.style.display= "none"; / / DIV hides div2.style.display= ""; / / DIV shows

2 [xss_clean], outerHTML,innerText,outerText

There is a classic code on the Internet about the difference between the four:

ThisisaDIV!

From this, we can clearly see the respective functions of the four:

InnerHTML: the html tag in div, through which you can easily set the content to be displayed in div, such as:

Document.getElementById ("div3") [xss_clean] = "hhh"

OuterHTMl: all html tags, including div

InnerText: the text to be displayed in div is basically the same as outerText.

It is worth noting that the above four are only valid under firefox, and the others are only available under IE.

On "DIV how to achieve show and hide operation" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Articles content more tags good practical effective clear from code functions only text articles methods knowledge classics references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS Apple Huawei Shulou Technology