Labels and hidden fields in Internet Explorer (and jquery)

前端 未结 5 1779
日久生厌
日久生厌 2021-02-05 12:36

I\'m having trouble checking hidden checkboxes in IE. This is the base html:



        
5条回答
  •  孤独总比滥情好
    2021-02-05 13:32

    Hidden checkboxes don't receive events in IE version below 9. My generalized solution is as follows:

    /* hide checkboxes */
    input[type=checkbox] {
        visibility: hidden;
        position: absolute; /* move out of document flow */
    }
    /* ie8-: hidden inputs don't receive events, move out of viewport */
    .lt-ie9 input[type=checkbox] {
        visibility: visible;
        top: -50px;
    }
    

    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.

提交回复
热议问题