如何使用JQuery隐藏和显示HTML元素?

如何在没有任何特殊效果的情况下使用JQuery隐藏和显示HTML元素?

使用hide()show()方法:

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

“选择器”是适当的。 喜欢:

  
This is some text

如果隐藏,则toggle()方法只调用show()否则调用hide()

 $('#someElement').show(); //an element with id of someElement $('.someElement').hide(); //hide elements with class of someElement $('a').hide(); //hide all anchor elements on the page 

看到:

http://docs.jquery.com/Effects/show

http://docs.jquery.com/Effects/hide

另外,阅读选择器是个好主意:

http://docs.jquery.com/Selectors

切换显示:

 $('selector').toggle(); 

节目:

 $('selector').show(); 

隐藏:

 $('selector').hide(); 

$(“selector”)。toggle()在隐藏和显示之间切换选定的DOM元素。 $(“selector”)。hide()隐藏选定的DOM元素。 $(“selector”)。show()显示选定的DOM元素。

说实话,我认为你可以解决这个问题,而不必咨询stackoverflow。 jquery文档非常清楚imo!

查看show,hide和toggle 的jQuery在线文档 。

隐藏元素:

 $('#myElement').hide(); 

显示元素:

 $('#myElement').show(); 

隐藏: http : //docs.jquery.com/Hide

显示: http : //docs.jquery.com/Show