How make li elements slide down and up?

前端 未结 5 1604
孤街浪徒
孤街浪徒 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:13

      I would recommend avoiding the styling with the fixed height.

      Add a style="display:none" on each

      :

    • click

      adasdanvljskljfklsdklfsdjfkljsdkljfklsdjklfjskldjfklsdjklfjsdkfjksjdklfjs;dfl;sdkf fsdfsdfsdfsfhowerjweklfjifjvjdfioverjgfioqwopiropqieopki

    • Then do this in your javascript:

      $(document).ready(function(){
         $('.expand').click(function(){
           $(this).parent().find("p").slideToggle();
         });
      });
      

      In this way you get to toggle each answer with the click action.

    提交回复
    热议问题