I'm having trouble checking hidden checkboxes in IE. This is the base html:
<input id="groups_ids_1" name="group_ids[]" type="checkbox" value="1" />
<label for="groups_ids_1">Display</label>
This works fine, but if I then hide the checkboxes using either
$('input[type=checkbox]').hide();
or
$('input[type=checkbox]').css('visibility', 'hidden');
Clicking the label no longer checks the checkbox in IE. Of course it works fine in Firefox, Chrome and Safari.
Hidden checkboxes don't receive events in IE version below 9. My generalized solution is as follows:
Don't move the inputs to the left or the page will jump in IE when the input receives focus!
.lt-ie8
is a class that is set on the HTML tag for old IE versions in this manner: (see eg: https://github.com/h5bp/html5-boilerplate/blob/master/index.html)But you can use your preferred method in order to apply the properties in the second rule to old IE version only. Applying the rules via JS should work too, as you seem to be doing.
The best way to avoid this, is to position the checkbox absolutely at top: -1000px;
As variant, instead
visibility: hidden;
ordisplay: none
, useclip: rect(0 0 0 0);
So instead
or
use something like
and
It works in normal browsers and in IE8
You could try added an onclick to the label to get around the IE issues.
If that does not work, try setting the attribute manually.
This worked for me in IE8: