How to make Twitter Bootstrap Collapse work on dynamically loaded html using ajax

后端 未结 3 1569
一向
一向 2021-02-14 12:32

I am loading html using ajax call, this html has Bootstrap Collapse. The issue is Collapse is not working, if you click it wil

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-14 12:51

    Just execute this on ajax success event.

    $('[data-toggle="collapse"]').click(function(e){
          e.preventDefault();
          var target_element= $(this).attr("href");
          $(target_element).collapse('toggle');
          return false;
    });
    

提交回复
热议问题