dpka7974 2012-01-19 13: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 13: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条)

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)