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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大