jQuery API | jQuery API 中英文对照版 - jQuery在线查询手册 |
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
Example: $("p").slideDown("slow"); Example: $("p").slideDown("slow",function(){ alert("Animation Done."); }); 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 $("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> ] |