X

JQuery live ‘change’ doesn’t work in IE

jquery

So was having issues as in why does my checkbox doesn’t work in IE when I do

  $('.checkbox').live('change', function() {
    alert('Checkbox clicked');
  });

And found out that jquery does not bind live “change” events, I was told that it works in 1.4.2 but for some reason I still was not able to get it working.

The solution that I found was to use the livequery or bind method thus the code would become

  $('.checkbox').bind('change', function() {
    alert('Checkbox clicked');
  });

or if you are using Ajax then

  $('.checkbox').livequery('change', function() {
    alert('Checkbox clicked');
  });

That should do the trick, remember to add jquery.livequery.js if you are using livequery in your file.

Categories: javascript JQuery
Taswar Bhatti:

View Comments (4)

  • I realize this post is over a year old, but I hope this is helpful to anyone else who stumbles upon it like I did.

    You need to make sure you are in fact setting class="checkbox" for your checkboxes if you are going to access them with $(".checkbox").live(...);

    . If not, you can access them using
    $("input[type="checkbox"]).live(...);

    Also, using live() is costly compared to other dynamic event handling methods, like bind() or delegate().

    • Yes I agree, but bind does not work in data that is dynamic I would recommend delegate better.

  • Use bind instead of live, was the solution on my problem IE dont work well with live because you must click on the form to get it work, then when i used bind it work like a charm regards ;)

Related Post