Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery hides a div

Shulou Source: shulou.com Published: 2022-06-01 11:38:29 09月18日 Update

This article mainly introduces how jquery hides a div. It is very detailed and has a certain reference value. Friends who are interested must read it!

Jquery hide a div method: 1, use "$(" div "). Hide ();" statement hide; 2, use "$(" div "). Toggle ();" statement hide; 3, use "$(" div "). Css (" display "," none ");" statement hide.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

The method of hiding div in jquery

Method 1: use the hide () method

The hide () method hides the selected element.

$(document) .ready (function () {$("button") .click (function () {$("div"). Hide ();}) This is a title. This is a div element.

This is another paragraph.

Delete div element

Method 2: use the toggle () method

The toggle () method toggles the visible state of the element.

If the selected elements are visible, they are hidden, and if they are hidden, they are displayed.

$(document) .ready (function () {$("button") .click (function () {$("div"). Toggle ();}) This is a title. This is a div element.

This is another paragraph.

Hide or show div elements

Method 3: use the CSS () method to set the display attribute for the element

$(document) .ready (function () {$("button") .click (function () {$("div") .css ("display", "none"); / / hide div});}) This is a title. This is a div element.

This is another paragraph.

Hide div elements

The above is all the content of the article "how jquery hides a div". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Element method this is title paragraph sentence content article value interest buddy attribute tutorial more version status environment computer knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Technology MariaDB Docker Microsoft