JQuery checkbox.val always on?

When using JQuery selectors and trying to get the value of a checkbox, it seems that it will always return the result “on”.  That is because you need to check to see if it is “:checked” instead of trying to grab the value of it.

if($("input[name='YourCheckboxName']").is(":checked")){
alert('on');
}else{
alert('off');
}

 

One Response to “JQuery checkbox.val always on?”

Leave a Reply