jQuery API jQuery API 中英文对照版
toggle()
toggle()

切换元素的可见状态。如果元素是可见的,切换为隐藏的;如果元素是隐藏的,切换为可见的。

返回值:jQuery

示例:

$("p").toggle()

HTML 代码:

<p>Hello</p><p style="display: none">Hello Again</p>

结果:

[ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]

 

slideDown( speed, callback )

Reveal all matched elements by adjusting their height and firing an optional callback after completion.

Only the height is adjusted for this animation, causing all matched elements to be revealed in a "sliding" manner.

Return value: jQuery
Parameters:

  • speed (String|Number): (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
  • callback (Function): (optional) A function to be executed whenever the animation completes, executes once for each element animated against.

Example:

 $("p").slideDown("slow");  

Example:

 $("p").slideDown("slow",function(){     alert("Animation Done.");   });  
toggle()

Toggles each of the set of matched elements. If they are shown, toggle makes them hidden. If they are hidden, toggle makes them shown.

Return value: jQuery
Example:

 $("p").toggle()  
Before:
 <p>Hello</p><p style="display: none">Hello Again</p>  
Result:
 [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]  
相关链接
WEB开发网 | PHP教程 | Mysql教程 | Apache教程 | 最新文章 | PHP面试题| 网站地图 | Google地图 | Baidu地图 | 在线WEB论坛

WEB技术QQ交流群:245735*** 站长Q号:245735***
版权所有者:WEB开发网 地址:云南省文山州砚山县盘龙乡 滇ICP备12002707号-10
特别声明:本站内容仅供参考,不作为设计及确切依据!想了解更多,可立即进入Bbs提问