0

here is my code :

<script>
    $(document).ready(function(){
        $(".checkbox").change(function(){
            alert("test")
        });

        $(".loadInto").load("test.php");
    }
</script>

<td id="loadInto" > </td>

test.php script return this code :

<input type="checkbox" class='checkbox'/>

I succeed to load the input checkbox but when I press on the checkbox, I didn't get alert. why ?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
user3648409
  • 293
  • 4
  • 10

1 Answers1

2

Try to use event-delegation at this context, since you are loading the elements at run time.

$('#loadInto').on('change', ".checkbox", function() {
  alert("test");
});

Note : In your code loadInto is an id not a class. Keep an eye on that.

So change your selector $("#loadInto").load("test.php");

Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130