Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use jquery to operate the display of div in html

Shulou Source: shulou.com Published: 2022-06-01 12:38:42 10月06日 Update

This article mainly shows you "how to use jquery in html to operate the display of div", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use jquery in html to operate the display of div" this article.

Examples

Div hide test hide or show

The content of div

("# controller") .click (function () {if ($("# contents"). Is (": hidden")) {$("# contents") .show ()} else {$("# contents") .hide ()})

Jqyery operation

$("# contents") .is (": hidden") can determine whether it is hidden or not

$("# contents") .show () represents display:block

$("# contents") .hide () represents display:none

Column

\ u7f51\ u7ad9\ u5f00\ u53d1\ u5fc5\ u5b66\ u4e4bHTML\ u8bed\ u8a00

Author:\ u521d\ u5b66\ u8005\ u4e4b\ u8def\ u5f20\ u8001\ u5e08

28 yuan

12 people have purchased

View

Manipulate the attributes of an element

$("# contents"). Attr ("style", "display:none;"); / / hide div

$("# contents"). Attr ("style", "display:block;"); / / display div

You can also manipulate the css property

$("# contents"). Css ("display", "none"); / / hide div

$("# contents"). Css ("display", "block"); / / display div

It can also be implemented directly using the toggle conversion switch.

("# contents") .toggle ()

The above is all the contents of the article "how to use jquery to operate the display of div in html". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content articles attributes learning help columns authors examples elements easy to understand more organization knowledge editing industry information information channels changeover switches channels testing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS Redmi Apple vpn