Prototype实战教程 12.Event.observe

<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

Prototype实战教程 12.Event.observe的相关文章

Prototype实战教程 13.Form.Element.Observer

<script src="prototype.js"></script> <form id="frm"> <div id="div1"> <input type="text" id="txt" name="txt" onchange="return alert('Now')"/> <input type

Prototype实战教程 8.顶层对象

<html> <head> <title>顶层元素</title> <script src="prototype.js"></script> <script> var Person=Class.create(); Person.prototype={ initialize:function(){}, name:'', birthday:'', age:'', Show:function(){alert(

Prototype实战教程 7.AJAX

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Ajax</title> <script type="text/javascript" langu

Prototype实战教程 6.$

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html> <head> <title>$</title> <script type="text/javascript" language="javascript" src="prototype.js" &g

Prototype实战教程 5.$R

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>$R</title> <script type="text/javascript" languag

Prototype实战教程 4.$H

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>$H</title> <script type="text/javascript" languag

Prototype实战教程 3.$F

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html> <head> <title>$F</title> <script type="text/javascript" language="javascript" src="prototype.js" &

Prototype实战教程 1.$$

<html> <head> <title>Test $$</title> <script src="prototype.js"></script> <script> function test$$(){ /**//* in case CSS is not your forte, the expression below says 'find all the INPUT elements that are

Prototype实战教程 16.string

<html> <head> <title>String Test</title> <script src="prototype.js"></script> <script> function testStrip() { var str=new String(' wanfangdata '); alert(str.strip()); } function teststripTags() { var str