dpka7974 2012-01-19 05:35
浏览 25
已采纳

扩展ul li列表底部的accordion / link

I have a bullet list as below:

<ul>
 <li>
  text1 here    
 </li>
 <li>
  text2 here    
 </li>
 <li>
  text3 here        
 </li>
 <li>
  text4 here        
 </li>
 <li>
  text5 here        
 </li>
 <li>
  text6 here        
 </li>
 <li>
  text7 here        
 </li>
</ul>

I only show the f1rst 3 bullets, but have a link at the bottom to show the rest if clicked (an accordion type effect). Ideally I would also have a close link to compress it again after it had been expanded.

What is the best way to do this with PHP & can I do this just with CSS?

Thanks

  • 写回答

4条回答 默认 最新

  • duange051858 2012-01-19 05:48
    关注

    Group link which you want to be hidden in Ex.

    <li>Text 1</li>
    <li>Text 2</li>
    <li>Text 3</li>
    <li class="hidden">
     <ul>
      <li>Text 4</li>
      <li>Text 5</li>
      <li>Text 6</li>
     </ul>
    </li>
    

    And use jQuery to attach accordion to it

    jQuery(document).ready(function(){
        $('a#trigger').click(function() {
            $('li ul.hidden').next().toggle('slow');
            return false;
        });
    });
    

    Of course you have to give display: none; to .hidden class http://docs.jquery.com/UI/Accordion

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部