Prototype 실전 강좌 ----13.Form.Element.Observer

1730 단어 prototypeGoogle

<script src="prototype.js"></script>
<form id="frm">
<div id="div1">
    <input type="text" id="txt" name="txt" onchange="return alert('Now')"/>
    <input type="text" id="txt2" name="txt2" />
    <input type="button" id="btn" name="btn"
        value="click" onclick="test(event)" />
    <input type="submit" />
    <a href="http://www.google.com" onclick="test2(event)">Google</a>
    <input type="button" id="btn1" name="btn1"
    value="click" onclick="test3(event)" />
</div>
</form>
<script>
function test(evt) {
    alert($("btn") === Event.element(evt));
}

function test2(evt) {
    alert("clicked");
    Event.stop(evt);
}

function test3(evt) {
    alert($("div1") === Event.findElement(evt, "div"))
}

new Form.EventObserver("frm", function () {
        alert("form changed");
    }
);

new Form.Element.EventObserver("txt", function () {
        alert("txt changed");
    }
);


new Form.Observer("frm", 1, function () {
        alert("form changed");
    }
);

new Form.Element.Observer("txt", 1, function () {
        alert("changed");
    }
);
</script>

좋은 웹페이지 즐겨찾기