开发者

Does the onchange attribute work in non-traditional elements?

Since events 开发者_开发问答bubble up in the DOM, it seems like a change event should be able to reach any container element (e.g. div, table, or ul elements). Therefore, it seems like any such elements should support the onchange attribute. However, it seems like only a few element types support this in the official standard.

Despite this, I was able to give a tbody an onchange attribute, which ran when I changed the contents of a text input within the tbody.

Will I experience the same thing if I use some other major browser + OS combination?


As described in the DOM Level 2 Events Specification, the change event is valid only for INPUT, SELECT, and TEXTAREA elements.

Edit: As @no kindly comments, the event according the W3C Standard bubbles up, the purpose of this is clearly to catch the event on other elements.

But I wouldn't recommend you to expect cross-browser bubbling with change for one reason: IE.

In their proprietary Event Model implementation, they explicitly describe that the change event does not bubble...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜