最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Make Internet Explorer recognize "advanced" CSS selectors - Stack Overflow

programmeradmin0浏览0评论

Do any JavaScript libraries exist that somehow make Internet Explorer (no particular version) recognize advanced CSS selectors, such as input[type="text"]?

I hate adding extra classes to HTML objects just to acmodate IE.

Do any JavaScript libraries exist that somehow make Internet Explorer (no particular version) recognize advanced CSS selectors, such as input[type="text"]?

I hate adding extra classes to HTML objects just to acmodate IE.

Share Improve this question edited Mar 6, 2014 at 19:55 Donald T asked Jun 13, 2011 at 16:22 Donald TDonald T 10.7k17 gold badges65 silver badges93 bronze badges 8
  • What version of Internet Explorer? IE9 is pretty good with many selectors. – BoltClock Commented Jun 13, 2011 at 16:24
  • Also, input[type=text] isn't all that advanced, seeing as CSS2.1 has already been finalized as a W3C Remendation after more than 10 years in development. w3/TR/CSS21 and IE supports that selector from version 7 and up. – BoltClock Commented Jun 13, 2011 at 16:27
  • @BoltClock That's why I put "advanced" in quotes ;) – Donald T Commented Jun 13, 2011 at 16:28
  • Just to clarify, there doesn't exist a javascript library that can make the browser properly parse advance css (via style/stylesheets) that it doesn't already understand, that functionality needs to be baked into the browser itself. – Quintin Robinson Commented Jun 13, 2011 at 16:29
  • 1 @venimus: No, only IE7+. – BoltClock Commented Jun 13, 2011 at 16:32
 |  Show 3 more ments

3 Answers 3

Reset to default 7

I can't believe this wasn't suggested:

http://selectivizr./

selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8. Simply include the script in your pages and selectivizr will do the rest.

Selectivizr works automatically so you don't need any JavaScript knowledge to use it — you won't even have to modify your style sheets. Just start writing CSS3 selectors and they will work in IE.

You also need to include a standard JavaScript library of your choice, which you're likely already doing.

IE7.js (and IE8.js and IE9.js): http://code.google./p/ie7-js/ do their best to bring prior versions of IE up to support for what the script names (e.g. IE8.js tries to make IE6/7 act like IE8). This includes, among other things, many attributes of CSS2/3, though you'll have to check to see exactly what is supported in which version.

if you just want to use the selectors in JS, http://sizzlejs./ supports all CSS2/3 selectors and is used as the base for many JS libraries.

so you want a javascript that changes the browsers css support? i'm pretty sure that's impossible.

your best bet is going to be putting whatever styles you want into a class, and in your document ready, do an .addClass

发布评论

评论列表(0)

  1. 暂无评论