在 col 元素中声明事件如何影响表的单元格?
当在 HTML 表格的 col 元素中声明事件(例如 onclick)时,该事件是否会影响 col 元素引用的单元格?该事件是否被忽略?还会发生其他事情吗?
When an event, such as onclick, is declared in a col element for an HTML table does that event impact the cells referenced by the col element? Is the event ignored? Does something else happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很好的问题。
规范说:
其中
%events
说:所以是的,它出现了事件应该支持
td
。然而,“应该”与“做到”相差甚远。唯一知道的方法是在所有浏览器中进行测试,并希望它也适用于未来的浏览器。
再想一想,只需使用 事件委托并绑定一次到父
表
。这将在现在和永远更有效。Great question.
The spec says:
where
%events
says:So yes, it appears events are supposed to be supported for the
td
s.However "supposed to" is a far cry from "does". The only way to know is to test in all browsers and hope it works in future browsers too.
On second thought, just use event delegation and bind once to the parent
table
instead. That will work now and forever more.