Object.Watch with disabled attribute
Posted
by
Benjamin Fleming
on Stack Overflow
See other posts from Stack Overflow
or by Benjamin Fleming
Published on 2010-12-29T01:06:16Z
Indexed on
2010/12/29
1:54 UTC
Read the original article
Hit count: 574
<html>
<head>
<script type="text/javascript">
window.onload = function() {
var btn = document.getElementById("button");
var tog = document.getElementById("toggle");
tog.onclick = function() {
if(btn.disabled) {
btn.disabled = false;
} else {
btn.disabled = true;
}
};
//btn.watch("disabled", function(prop, val, newval) { });
};
</script>
</head>
<body>
<input type="button" value="Button" id="button" />
<input type="button" value="Toggle" id="toggle" />
</body>
</html>
If you test this code, the Toggle button will successfully enable and disable the other button.
However, un-commenting the btn.watch() line will somehow always set the disabled tag to true.
Any ideas?
© Stack Overflow or respective owner