jquery show()/hide() problem in Internet Explorer?

前端 未结 3 1477
有刺的猬
有刺的猬 2020-12-20 16:37

The following html code works in Firefox, but for some reason fails in IE (Label2 is not shown). Is that a bug or I miss something?

Any help would be appreciated.

3条回答
  •  天命终不由人
    2020-12-20 17:15

    Remember that the onchange event is triggered after you check the checkbox and then leave the checkbox. Did you try checking it, then clicking somewhere else on the document?

    You may want to employ the click and keypress events in jQuery instead (for checking the box via click and spacebar).

    Is there any reason you're declaring/defining a function within your document ready paragraph, rather than outside of it?

    One more edit; may I recommend this sleeker code:

    jQuery(document).ready(function(){
        $("#g_1").hide();
        $("#check").change(function() { $("#g_1").toggle(); });
    });
    

提交回复
热议问题