Prototype笔记(八)----Event扩展

本文介绍了如何使用observe方法为DOM元素添加事件监听器。通过两个示例展示了如何为窗口加载事件和输入框聚焦事件添加处理函数。这有助于理解事件监听器的工作原理及其在不同阶段的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

observe(element, name, observer, useCapture) static element: object or id, name: event name (like 'click', 'load', etc), observer: function to handle the event, useCapture: if true, handles the event in the capture phase and if false in the bubbling phase. 为对象的某个事件增加一个处理函数。

<script>
Event.observe(window, 'load', showMessage, false);
function showMessage() {
alert('Page loaded.');
}
</script>


<script>
Event.observe($(inc_SchoolName[mark]), 'focus', function() {shows(mark)});

</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值