Possible Duplicate:
How do I check if a checkbox is checked with JQuery?
I have a following form which opens in light box
<form name="adminFormMod" id="adminFormMod" action="index.php" method="post"> <input type="text" name="myname" value="sss"/> <input type="checkbox" name="test" id="test" value="tttt" /> <input type="button" value="submit" onclick="updateresults()"/> </form> On the js page which includes on the above page when i try to check weather the checkbox is checked or not.my following code is not working
alert(document.getElementById('test').checked); the above always alert the fasle
Even with following jquery line of code
$('#adminFormMod').find(':input').each(function() { // alert('idhar'); switch(this.type) { case 'text': //alert('text'); $(this).val(''); break; case 'checkbox': //alert($(this).attr('checked')); if($(this).attr('name')=='test') { alert(this.checked); alert($(this).attr('checked')); } break; } } ); it always alert the false even the checkbox is checked.Please help