0
$(document).ready(function(){
    $(".click").on('click', function(){
        var target = $(this).parent().children(".expand");
        $(target).slideToggle();
    });
});

HTML content loaded by AJAX:

<div class="click" >...div with expand ....</div>
<div class="click" >...div with expand ....</div>

Can any one correct my code? Thanks in advance!

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339

1 Answers1

1

<div class="click"></div> is dynamically created element so we need to use the event delegation here.

Reference: Event binding on dynamically created elements?

Try This,

$(document).on('click', '.click', function(){
    // Do something
});
Community
  • 1
  • 1
Rakesh Kumar
  • 2,705
  • 1
  • 19
  • 33