Hello, I've faced strange problem. While user change of check box input element on form produces adequate event programmatic change don't. How should I face this challenge? Code following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(
function() {
jQuery("#cb").change(
function() {
alert("Changed!");
return true;
}
);
jQuery("#b").click(
function() {
var newState = !jQuery("#cb").attr('checked');
jQuery("#cb").attr('checked', newState);
});
});
</script>
</head>
<body>
<form action="#">
<p>
<input type="button" id="b" />
<input type="checkbox" id="cb" />
</p>
</form>
</body>
</html>
Update I do not control element changes, I just need to handle them. It's general-propose code I write.