Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery hides elements

Shulou Source: shulou.com Published: 2022-06-01 06:15:39 09月18日 Update

This article mainly introduces how jquery hides elements, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

jquery Hidden element code: 1,"$(selector).hide();";2,"$(selector).toggle(1000);";3,"$(selector).slideDown();";4,"$(selector).css("display","none")."

This tutorial operates on Windows 7, jquery version 1.10.2, Dell G3 computers.

There are several ways to hide elements in jquery:

1. Use hide()

hide() hides visible elements:

$("button").click(function(){ $("p").hide();});

hide() is often used in conjunction with show to switch between overt and covert

show() shows hidden elements.

$("button").click(function(){ $("p").show();});

Use the toggle() method

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

Hides selected elements if they are visible, and displays them if they are hidden.

$("button").click(function(){ $("p").toggle(1000);});

3. Use slideDown() method

Show hidden elements by sliding

$("button"").click(function(){ $("p").slideDown();});

Use CSS() method

Use the css() method to style displays to hide visible elements:

$("button"").click(function(){ $("p").css("display","none"); //}); Thank you for reading this article carefully. I hope that the article"jquery how to hide elements "shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Tags: Elements methods articles selection switching code value interests at the same time multiple tutorials ways more friends styles versions status environment computer knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple Shulou Tech Info OPPO Reno vpn