Home > Article > Web Front-end > What are the codes for hiding elements in jquery
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")".
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!