代码之家  ›  专栏  ›  技术社区  ›  4imble

当您将<div>设置为隐藏时,JQuery对它做了什么?

  •  5
  • 4imble  · 技术社区  · 16 年前

    我想知道JQuery对 <div> 当你把它藏起来的时候?

    它只是将CSS显示样式设置为none吗?

    我问的原因是,我想 <部门>

    4 回复  |  直到 11 年前
        1
  •  9
  •   Nick Craver    16 年前

    它设定为 display: none ,虽然有一些额外的工作,但这是总体效果。

    <div style="display: none;"> 然后 .show()

    Here's a quick demo showing this

    如果你更好奇 发生了什么,你总是可以直接看源:)的 .hide() http://github.com/jquery/jquery/blob/master/src/effects.js#L59

    两者的主要区别 / .show() 和 .css('display':'whatever') .show() 恢复 display ),而不是选择一个新的:)

        2
  •  3
  •   Dan McGrath    16 年前

    JQuery API with speed set to none, yes

    ):

    When a duration is provided, .hide() becomes an animation method. 
    The .hide() method animates the width, height, and opacity of the 
    matched elements simultaneously. When these properties reach 0,
    the display style property is set to none to ensure that the element
    no longer affects the layout of the page.
    
        3
  •  0
  •   Ololo    16 年前

        4
  •  0
  •   Sarfraz    16 年前

    它只是简单地设置它的CSS显示吗

    是的 ,它就是这样做的,例如它设置:

    display: none;