将鼠标事件添加到 colgroup 或 col
是否可以在 cols 或 colgroups 上添加 jQuery 鼠标事件。我们曾尝试这样做,但似乎没有效果。另一方面,这些列有真实的宽度和高度。有没有办法让这些事件与 col 一起工作?
Is it possible to add jQuery mouse events on cols or colgroups. We have tried to do so, but it didn't seem to work. On the other hand those cols have a real width and height. Is there a way to make those event work with col?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定是否可以为 colgroup 提供对组中任何单元格上的事件做出反应的处理程序。
您也可以为组中的每个单元指定一个特定的类。不过,如果“很多”的话,效果就不好。
一旦获得了 cols1 的句柄,请保留它,直到表格单元格的 DOM 结构发生变化。您不必通过选择器不断迭代 DOM 来获取匹配的 DOM 元素集合。
I'm not sure that a colgroup can be given handlers that would react to events over any cell in the group.
You could alternatively give each cell in the group a specific class. Although, if there are a "lot", it wouldn't perform well.
Once you get a handle on cols1, keep it until the DOM structure of the table cells change. You won't have to keep iterating the DOM via the selector to get the collection of DOM elements which match.
您也许能够使用 nth-child 选择器实现您的目标: http:// api.jquery.com/nth-child-selector/
You might be able to achieve what you're after using the nth-child selector: http://api.jquery.com/nth-child-selector/