Anthony Main
Anthony Main

Reputation: 6068

jQuery Click/Change event not working properly in IE7/8

I am binding an event to a checkbox's change or click event which works fine in Firefox but in IE I have to click anywhere else (causing the blur) event before the event is fired.

I have read and believe this is down to the way IE fires the events, but is there anyway I can get round it?

The whole point is that it is a smooth search feature which doesn't need a search button to be clicked

$('#sidebar .itemSearchModule-Form input[type=checkbox]').click(function() {
    $('#sidebar .itemSearchModule-Form .saveButton').click();
});

Upvotes: 4

Views: 4130

Answers (3)

Anthony Main
Anthony Main

Reputation: 6068

Paolo Bergantino was right so this answer credit should go to him.

It seems my code was all screwed up and another selector was getting tied up with the sample I used above.

The CLICK event does work in IE I can confirm, if you are suffering the same problem ALL I can suggest is you check your code

Upvotes: 1

Noam Smadja
Noam Smadja

Reputation: 1035

try giving that checkbox a class like chkbx and try:

$('.chkbx').click(function() { etc...

its just for debuggin your selector.. being sure problem is in the action. i think for IE you need to use GetElementByID.

Upvotes: 0

Alex Sexton
Alex Sexton

Reputation: 10451

The change event requires a blur to happen first. The Click event should not. You could always force a blur event if you wanted by $(elem).blur()

Upvotes: 1

Related Questions