How make li elements slide down and up?

前端 未结 5 1550
孤街浪徒
孤街浪徒 2021-01-26 07:22

I have

  • elements in a
      and I want them expand down and up and each element should expand down and up.

      HTML:

      
      
              
  • 5条回答
    •  不思量自难忘°
      2021-01-26 08:06

      You need to make it element-specific instead of selecting all elements with the class (by referencing this)

      For your markup, you could combine this with parent():

      $(document).ready(function(){
         $('.expand').click(function(){
           $(this).parent().css('height','auto');  
         });
      });
      

      jsFiddle here

    提交回复
    热议问题