所有浏览器都支持 querySelector 吗?
我想知道所有浏览器都支持 querySelector 吗?不是有什么替代品可以使用吗?
我已经用 IE8、FF3、Chrome 4 进行了测试。它对我来说很好。我没有旧的浏览器。所以我想知道旧浏览器是否会给我带来问题?
I would like to know is querySelector supported by all browsers? is not what's alternate for it to use?
I have tested it with IE8, FF3, Chrome 4. Its fine for me. I do not have old browsers. So i would like to know if old browsers will give problem to me or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
IE7<不支持它,并且 IIRC IE8 存在命名空间问题。至少还有一种深奥的浏览器存在重大问题,但我不记得是哪一种了。
基本上没有统一的基于表达式的 DOM 方法,并且绝对最好的选择是使用库(无处不在的“使用 jquery”答案,但您至少应该查看 Sizzle(如果您对大型库有问题),因为自己开发库比合理值得付出的努力要多(我从经验来看)。
IE7< don't support it and IIRC IE8 has issues with namespaces. There's at least one more esoteric browser out there with major issues but I don't recall which it is.
Basically there is no unified expression-based DOM method, and absolutely your best bet is to use a library (the ubiquitous "use jquery" answer, but you should at least check out Sizzle if you have a problem with large libraries) because rolling your own is more effort than reasonably worthwhile (I speak from experience).
QuerySelector 在 Firefox 3.1+、IE8+(仅在 IE8 标准模式下)和 Safari 3.1+ 浏览器上受支持。
支持文章
QuerySelector is supported on Firefox 3.1+, IE8+ (only in IE8 standards mode), and Safari 3.1+ browsers.
supporting article
我用 FireFox 对其进行了测试 - 效果非常好。
在 IE 中,当您使用怪异模式的文档时出现问题(不使用 DOCTYPE HTML)
尝试在 HTML 文档中使用
I tested it with FireFox - It is perfectly work.
In IE there is a issue when you use the document with quirk mode (without using DOCTYPE HTML)
Try to use in the HTML document
您可以查看 MDN 了解详细信息。
You can check MDN for detail information.
最好的替代方案是使用第三方库来抽象所有讨厌的特定于浏览器的代码,例如 YUI 或 jQuery(我对 Prototype 等人不太熟悉,所以我不能确定它是否使用
query*
方法[如果可用])。The best alternative is to use a third-party library that abstracts all that nasty browser-specific code away, like YUI or jQuery (I'm not as familiar with Prototype et al, so I can't say for sure if it uses the
query*
methods [when available]).