亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery實(shí)現(xiàn)折疊菜單效果【推薦】

 更新時間:2017年03月08日 15:20:46   作者:IT白菜哥  
本文主要介紹了jquery實(shí)現(xiàn)折疊菜單效果的實(shí)例,具有很好的參考價值。下面跟著小編一起來看下吧

這是一個簡單的折疊框效果實(shí)現(xiàn),核心內(nèi)容jQ庫里的slideToggle()方法

效果圖如下:

css代碼:

  .con_ul{

  padding: 0;
  margin: 0;
  overflow: auto;
  }
  .con_ul li{
  list-style: none;
  padding: 10px;
  margin: 0;
  border-bottom: 1px solid #CCCCCC;
  }
  .con_ul li .title{
  padding-right: 20px;
  background-image: url(images/drop_1fcaf417.png);//默認(rèn)的背景
  background-position: 100% 0px;
  background-repeat: no-repeat;
  }
  .con_ul li .title.act{
  padding-right: 20px;
  background-image: url(images/top.png);//展開后的背景
  background-position: 100% 0px;
  background-repeat: no-repeat;
  }
  .con{
  background-color: #F4F4F4;
  display: none;//內(nèi)容本分默認(rèn)隱藏
  padding: 5px;
  margin: 10px 0;
  }

html代碼:使用ul li的布局本菜認(rèn)為代碼結(jié)構(gòu)更簡潔清晰

 <ul class="con_ul">
  <li>
  <div class="title">
   標(biāo)題
  </div>
  <div class="con">
   內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容
</div>  
  </li>
  <li>
  <div class="title">
   標(biāo)題
  </div>
  <div class="con">
   內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容
</div>  
  </li>
  <li>
  <div class="title">
   標(biāo)題
  </div>
  <div class="con">
   內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容內(nèi)容
</div>  
  </li>
 </ul>

javascript代碼:

 <script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
 <script>
  $('.con_ul li .title').click(function(){    
  $(this).toggleClass('act');//獲取當(dāng)前點(diǎn)擊對象,切換act類,達(dá)到切換背景箭頭的效果
  $(this).next().slideToggle();/獲取當(dāng)前點(diǎn)擊對象的下一個兄弟級,實(shí)現(xiàn)折疊效果切換  
  })
 </script>

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!

相關(guān)文章

最新評論