Home >Web Front-end >JS Tutorial >Detailed explanation of how jquery and js implement hiding and displaying divs

Detailed explanation of how jquery and js implement hiding and displaying divs

高洛峰
高洛峰Original
2017-03-12 14:25:461205browse

Detailed explanation of this articlejqueryandjsHow to hide and display div

jquery and js can hide and display p respectively, and the methods are also different Same, jquery's show, show; js's hidden, visible

jQuery's display and hiding of p:

Display:

The code is as follows:

$("#id").show()


Hide:

The code is as follows:

$("#id").show()

js displays and hides p:

p visibilityYou can control the display and hiding of p, but the page will be blank after hiding it

The code is as follows:

style="visibility: none;"
document.getElementById("typep1").style.visibility="hidden";//隐藏
document.getElementById("typep1").style.visibility="visible";//显示


Passed Setting the display attribute can release the occupied page space after p is hidden, as follows

The code is as follows:

style="display: none;"
document.getElementById("typep1").style.display="none";//隐藏
document.getElementById("typep1").style.display="";//显示


The above is the detailed content of Detailed explanation of how jquery and js implement hiding and displaying divs. For more information, please follow other related articles on the PHP Chinese website!

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