I want to get the value of the check box in the result variable. But I get the value as 'undefined' in the alert box. What is my mistake?
var result = ""; $("#required").change(function (){ result= $(".mycheckbox:checked").val(); alert(result); }); <div class=".mycheckbox"> <input id="required" type="checkbox" title="Required" name="required" value="required"> <label for="required">Required</label> </div>