Home > Web Front-end > JS Tutorial > body text

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

高洛峰
Release: 2017-03-12 14:25:46
Original
1117 people have browsed it

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()
Copy after login
Copy after login


Hide:

The code is as follows:

$("#id").show()
Copy after login
Copy after login

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";//显示
Copy after login


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="";//显示
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!