js accordian效果
生活随笔
收集整理的這篇文章主要介紹了
js accordian效果
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
學習筆記:
1.$(this)與this的區別
$()返回的都是jquery對象。this表示當前的上下文。
$(this)返回當前的jquery對象
this返回的是html對象
所以調用jquery方法只能使用$(this)
2.is方法
is() 根據選擇器、元素或 jQuery 對象來檢測匹配元素集合,如果這些元素中至少有一個元素匹配給定的參數,則返回 true。
.is(selector)
源碼:
/*jQuery time*/
$(document).ready(function(){
$("#accordian h3").click(function(){
//slide up all the link lists
$("#accordian ul ul").slideUp();
//slide down the link list below the h3 clicked - only if its closed
if(!$(this).next().is(":visible"))
{
$(this).next().slideDown();
}
})
})
轉載于:https://blog.51cto.com/baigungun/1285429
總結
以上是生活随笔為你收集整理的js accordian效果的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android - 常用知识点以及代码片
- 下一篇: Manager使用介绍