Home  >  Article  >  Web Front-end  >  What are the codes for hiding elements in jquery

What are the codes for hiding elements in jquery

青灯夜游
青灯夜游Original
2022-03-11 12:04:564057browse

jquery hidden element code: 1. "Specify element object.hide();"; 2. "Specify element object.toggle(1000);"; 3. "Specify element object.slideDown(); "; 4. "Specify element object.css("display", "none")".

What are the codes for hiding elements in jquery

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

Many ways to hide elements in jquery:

1. Use hide()

hide() can hide visible elements:

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

hide() is often used together with show to switch between visible and hidden elements.

show() can display hidden elements.

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

2. Use the toggle() method

toggle() method to switch the visible state of the element.

If the selected elements are visible, then hide these elements. If the selected elements are hidden, then display these elements.

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

3. Use the slideDown() method

Show hidden elements in a sliding manner

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

4. Use the css() method

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

$("button"").click(function(){
  $("p").css("display","none");
  //
});

[Recommended learning: jQuery video tutorial, web front-end video

The above is the detailed content of What are the codes for hiding 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:What is jquery?Next article:What is jquery?