Home > Web Front-end > Front-end Q&A > How to hide elements in jquery

How to hide elements in jquery

青灯夜游
Release: 2021-11-12 18:05:51
Original
5713 people have browsed it

Method: 1. Use "$(selector).css('display','none');"; 2. Use "$(selector).attr("display","none" );"; 3. Use "$(selector).hide();"; 4. Use "$(selector).toggle();".

How to hide elements in jquery

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

Four ways to hide and display elements in jquery

Method one:

$(selector).css('display','none');
$(selector).css('display','block');
Copy after login

Method two:

$(selector).attr("display","none");
$(selector).attr("display","block");
Copy after login

Method 3:

$(selector).hide();
$(selector).show();
Copy after login

hide() method: If the selected element has been displayed, hide the element.

show() method: If the selected elements have been hidden, display these elements

Method 4:

$(selector).toggle();
Copy after login

toggle() method in Switch between hide() and show() on the selected element.

This method checks the visible status of the selected element. If an element is hidden, show() is run, if an element is visible, hide() is run - this creates a toggle effect.

Recommended related video tutorials: jQuery Tutorial (Video)

The above is the detailed content of How to hide elements in jquery. 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