4

I have no idea why this wont work but I have tried the following:

$('#elemid').prop('checked', true);
$('#elemid').attr('checked', true);
$('#elemid').attr('checked', 'checked');

IE9 just absolutely refuses to actually check the box when the code is run. I know the code is being run due to console.log.

However no checked element.

This code works perfectly in FF and Chrome. Am I missing something here?

7
  • 1
    It works, tested in ie9, jsfiddle.net/5Yycf Commented Apr 4, 2012 at 6:32
  • My guess is you have forgotten to run the code on documentReady using the $(function() { ... }); construction. Commented Apr 4, 2012 at 6:34
  • .prop() is included in jquery version 1.6, Make sure you have the right version., and this will be support by IE9 , hope you might have done a small mistake around. the browser prior to IE9 will have memory leaks in using prop() hope you didn't forgot about it. Commented Apr 4, 2012 at 6:41
  • My sample code above is not the same as the actual code. And its within a scope of a large app so reposting the exact code here wont work. I'm ripping my hair out over this. -- The code has nothing to with doc ready. Its a toggle function that gets executed when a link is clicked. Commented Apr 4, 2012 at 6:42
  • I'm using latest jquery. Commented Apr 4, 2012 at 6:43

1 Answer 1

0

Ok, my problem was incredibly stupid.....

I had each checkbox inside a floated labels. why I used labels for this is beyond me, but the label was also registereing a click which was unchecking the box immediately after my code "checked" the box.

I was able to fix the issue by moving the input's out side of the label fields (they are display: none anyway)

The whole point of this is a fancy checkbox system with logos instead of check boxes. The background of the label changes when its click to show active selection etc etc.

Thanks for the help guys.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.