<script src="prototype.js"></script>
<input type="button" id="btn" value="click" />
<input type="button" id="reg" value="register" />
<input type="button" id="unreg" value="unregister" />
<div id="status"></div>
<script>
function test() {
alert("clicked");
}
Event.observe("reg", "click", function () {
Event.observe("btn", "click", test, false);
$("status").innerHTML = "event registered";
}, false
);
Event.observe("unreg", "click", function () {
Event.stopObserving("btn", "click", test, false);
$("status").innerHTML = "event unregistered";
}, false
);
</script>
时间: 2024-10-31 16:29:11