Issue
In many cases, I have checkboxes as below
<input type="checkbox" name="custom7" value="1" id="custom7"
checked="checked"> <label for="custom7">Email me more info?</label>
Now when the checkbox is checked the value should be 1 as in value=1 . If the checkbox is unchecked, I want the value to be zero as in value=0. How can I do this?
Solution
Thanks worked as in
$('#custom7').on('change', function(){
this.value = this.checked ? 1 : 0;
// alert(this.value);
}).change();
link: http://jsfiddle.net/WhQaR/
Answered By - Hello Universe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.