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

How to hide elements in jquery

青灯夜游
青灯夜游Original
2021-11-12 18:05:515760browse

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');

Method two:

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

Method 3:

$(selector).hide();
$(selector).show();

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();

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!

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
Previous article:Is jquery mvc?Next article:Is jquery mvc?