事件冒泡和onblur事件

事件冒泡和onblur事件

本文介绍了事件冒泡和onblur事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写表单验证脚本,并希望在其onblur事件触发时验证给定字段。我还想使用事件冒泡,所以我不必将onblur事件附加到每个单独的表单字段。不幸的是,onblur事件并没有泡沫。只是想知道是否有人知道可以产生相同效果的优雅解决方案。

I'm writing a form validation script and would like to validate a given field when its onblur event fires. I would also like to use event bubbling so i don't have to attach an onblur event to each individual form field. Unfortunately, the onblur event doesn't bubble. Just wondering if anyone knows of an elegant solution that can produce the same effect.

推荐答案

ppk有一种技巧,包括IE的必要解决方法:

ppk has a technique for this, including the necessary workarounds for IE: http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html

这篇关于事件冒泡和onblur事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 23:39