如何选择<表>就像;在 MS Html 编辑器中?表>
如果插入了 DIV、MARQUEE 或 IMG 等标签,则单击标签区域中的任意位置即可选择该标签。但是,如果插入了TABLE,则只有单击标签区域的边框才能选择它。我搜索了为 DIV 定义的可能事件(onclick
、keydown
),但遗憾的是没有找到相关的 Javascript 代码。 DesignMode 用于编辑器。有人知道如何让 TABLE 像 DIV 一样更容易被选择吗?
If a tag like DIV, MARQUEE or IMG is inserted, it can be selected when clicking anywhere in the tag area. However, if a TABLE is inserted, it can only be selected when clicking on the border of tag area. I have searched for the possible event (onclick
, keydown
) defined for DIV, but unfortunately no relevant Javascript code was found. DesignMode is used for the editor. Anyone knows how to make TABLE easier to be selected just like a DIV?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
ControlRange
并选择它来完成此操作。假设表元素存储在名为“table”的变量中:jsFiddle: http://jsfiddle.net/DTK8j/
You can do it using a
ControlRange
and selecting it. Assuming the table element is stored in a variable called "table":jsFiddle: http://jsfiddle.net/DTK8j/
这可能意味着创建了表,以便为每个单元格定义一个事件,并且可能每行也有一个事件。当您单击行中的任何区域时(如果没有为单元格指定填充),单元格事件将被触发并首先检测单元格事件而不是行事件。同样,单击行将触发行事件而不是表事件。
所以这很困难,但是如果您没有定义任何事件(例如 onclick)或每行或单元格上的任何事件,那么您只能获得表格事件;否则,任何行或单元格上定义的事件将优先于表事件被激活。
It probably means that table was created so that an event was defined for each cell and possibly each row has an event also. When you click on any area in the row (if there was not padding given for the cell) the cell event was fired up and detect the cell event first not the row event. Likewise the click on the row will trigger the row event rather than the table event.
So it's difficult, but if you didn't define any event like onclick or any event on each row or cell then you only get the table event; otherwise the defined event on any row or cell will be activated in preference to the table event.