Get checkbox value
Description
The following code shows how to get checkbox value.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.6.4.js'></script>
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css">
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!--from www . j a v a 2s .com-->
$("#divCheckbox").click(function() {
var checkbox = $(this).find("input[type='checkbox']");
alert(checkbox.prop("checked"));
var label = $(this).find(".ui-checkbox-on");
checkbox.prop("checked", label.length);
});
});//]]>
</script>
</head>
<body>
<div data-role="fieldcontain" id="divCheckbox">
<fieldset data-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-1" id="checkbox-1"
class="custom" />
<label for="checkbox-1">I agree</label>
</fieldset>
</div>
</body>
</html>