在我的 CSS 中,我有一个必须应用于所有文本字段的规则(使用 CSS3 选择器input[type=text]
.
我也使用jQuery。某些浏览器(例如 Internet Explorer 6)不支持 CSS 选择器的这种形式。所以我的解决方法是在 CSS 中添加一个额外的类名:
input[type=text], .workaround_classname{
/* css styling goes here */
}
然后通过 jQuery 添加 CSS 类:
$('input[type=text]').addClass('workaround_classname');
问题是:如何确保仅当 CSS3 选择器不受本机支持时才调用此规则?