Home >Web Front-end >JS Tutorial >jquery and js implement methods to hide and show divs_jquery

jquery and js implement methods to hide and show divs_jquery

WBOY
WBOYOriginal
2016-05-16 16:35:211029browse

jQuery showing and hiding divs:

Display:

Copy code The code is as follows:

$("#id").show()

Hide:
Copy code The code is as follows:

$("#id").show()

JS shows and hides divs:

The visibility of the div can control the display and hiding of the div, but the page will appear blank after hiding it

Copy code The code is as follows:

style="visibility: none;"

document.getElementById("typediv1").style.visibility="hidden";//Hide

document.getElementById("typediv1").style.visibility="visible";//Display

By setting the display attribute, you can hide the div and release the occupied page space, as follows

Copy code The code is as follows:

style="display: none;"

document.getElementById("typediv1").style.display="none";//Hide

document.getElementById("typediv1").style.display="";//Display
Statement:
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