Labels and hidden fields in Internet Explorer (and jquery)

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

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



        
5条回答
  •  清歌不尽
    2021-02-05 13:17

    Marc Diethelm : Hidden checkboxes don't receive events in IE version below 9.

    As variant, instead visibility: hidden; or display: none, use clip: rect(0 0 0 0);

    So instead

    $('input[type=checkbox]').hide();
    

    or

    $('input[type=checkbox]').css('visibility', 'hidden');
    

    use something like

    $('input:checkbox').addClass('hidden');
    

    and

    input[type=checkbox].hidden {
        clip: rect(0 0 0 0);
        position: absolute; /* move out of document flow */
    }
    

    It works in normal browsers and in IE8

提交回复
热议问题