WEB开发网
开发学院网页设计JavaScript Prototype实战教程----12.Event.observe 阅读

Prototype实战教程----12.Event.observe

 2010-09-14 13:10:11 来源:WEB开发网   
核心提示:<script src="prototype.js"></script><input type="button" id="btn" value="click" /><input type="

<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>

Tags:Prototype 实战 教程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接