表格行突出显示
一直在网上寻找进行表行突出显示的“最佳”方法。
似乎两个主要替代方案是:
1 纯 CSS:tr:hover
2 Css + Jquery:
$("table").delegate('td','mouseover mouseleave', function(e) {
if (e.type == 'mouseover') {
$(this).parent().addClass("tr-hover");
}
else {
$(this).parent().removeClass("tr-hover");
}
});
我不知道现在什么被认为是最佳实践。据我所知,只有 IE7 不能与纯 CSS 选项正常工作。
或者,我应该考虑其他选择吗?
Been scouring the net for the 'best' way to do table row highlighting.
Seems that the two main alternatives are:
1 Pure CSS: tr:hover
2 Css + Jquery:
$("table").delegate('td','mouseover mouseleave', function(e) {
if (e.type == 'mouseover') {
$(this).parent().addClass("tr-hover");
}
else {
$(this).parent().removeClass("tr-hover");
}
});
I have no idea what is considered best practise these days. As far as I can ascertain, its only IE7 that doesn't work properly with the Pure CSS option.
Or, are there other alternatives that I should consider?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 CSS
:hover
方法。如果设置了 DOCTYPE,它也适用于 IE7+。此声明得到这篇 MSDN 文章。根据个人测试(以及 此来源),在以下情况下,标准兼容模式未激活:
或者当设置了 DOCTYPE,并且:
http://
也有效,其他协议无效。它可以与所有其他 DOCTYPE 一起激活,包括 XHTML、XML 和未知的 DOCTYPE。
CSS 的优点:
jQuery 的优点:
(这个标记并不是那么重要,所以这不会有很大的权重。顺便问一下,谁在使用 IE6?)。
Use the CSS
:hover
method. It does also work in IE7+, provided that a DOCTYPE is set. This statement is backed-up by this MSDN article.According to personal tests (and by this source), standards-compliant mode is not activated when:
or when the DOCTYPE is set, and:
http://
is also valid, other protocols are invalid.It is activated with all other DOCTYPEs, including XHTML, XML, and unknown ones.
Pros for CSS:
Pros for jQuery:
(this markup is not that critical, so this would not have a big weight. Who is using IE6 by the way?).