android - Javascript Checkboxes always returns true on mobile device -


i having js code using html checkboxes.

so far works great - when view on computer.

as view website on mobile device not work more.

i started debugging , noticed value of checkboxes come true on iphone , android.

to make setup more clear, please take look:

<input type="checkbox" name="aa" value="aa" id="aa" checked="true"     onclick='function2()'> <script> function function2() { alert(jquery('#aa').is(':checked')); } </script> 

the alert message return true, no matter if box checked or not. happens on mobile phones, works flawlessly on pc.

any ideas why happening?

i'm not able reproduce behavior, below code works fine me. maybe testing code help.

also, try editing checked="checked" 'checked'. http://www.w3schools.com/tags/att_input_checked.asp

<input type="checkbox" name="aa" value="aa" id="aa" checked> <script>      $('#aa').click(function() {         if($(this).is(":checked")) {             alert("checked");         } else {             alert("not checked");         }     }); </script> 

Comments