开发者

querySelectorAll throws DOM Exception when selector contains forward slash

Possibly a daft question, but I'm having trouble with document.querySelectorAll().

I'm trying to find a tag with a mime-type as it's property. For example

document.querySelectorAll('style[type=text/css]');

On Chrome 9, this throws the following error

Uncaught Error: SYNTAX_ERR: DOM Exception 12

If I omit the type attribute, it does not throw an error. If I remove the forward slash it also does not throw an error (but obviously does not return any nodes).

I know there are simple work arounds getting all elements, a开发者_开发知识库nd testing each one for it's type property, but I curious why this isn't working. Do I need to escape the forward slash? Or perhaps is this simply not a supported selector in Chrome 9?


Have you tried

document.querySelectorAll('style[type="text/css"]');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜