javascript - Why is the 'label' tag not working in ie8 -
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <input type="checkbox" name="check" style="display:none;" value="check1" id="ch1"> <label for="ch1">check1</label> <input type="checkbox" name="check" style="display:none;" value="check2" id="ch2"> <label for="ch2">check2</label> </body> </html> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script> function showvalues() { alert(this.value); } $( "input[type='checkbox']" ).on( "click", showvalues ); </script>
it work below picture in ie10 when click "check1" text
but not working in ie8
move <script>
tags inside <body>
.
i think want register clicks on labels instead of checkboxes (since not displaying checkboxes). try this:
function showvalues() { alert($("#"+$(this).attr("for")).val()); } $("label").on("click", showvalues);
Comments
Post a Comment