In the new features of IE8, I mentioned that querySelector () and querySelectorAll () methods are supported. I won't talk about how to use them here. I just recorded a problem I encountered during usage. When querySelector () or querySelectorAll () is used to find an element similar to name = "2nd_btn", FF, chrome, and IE8 will report an error.
FF, chrome reports the same error, as shown below:
Error: uncaught exception: [Exception... "An invalid or illegal string was specified" code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)" location :"... /test/qsa.html Line: 18 "]
The error message of IE8 is "row: 18". The parameter is invalid.
After removing or modifying the number, the name value starts with a number.
This tells us that when the attribute value of a tag can be customized, the attribute value cannot start with a number or contain uncommon characters such as $, ^.
Remember to declare it on the HTML page.
Test code:
The Code is as follows:
This is a sample warning
This is a sample error
This is another sample warning
This is another sample error
Script
Var a = document. querySelectorAll ("[name = warns]")
Alert (a. length) // output: 2
Var B = document. querySelector ("[id = 3err]")
Alert (B. tagName) // Error
Var c = document. querySelectorAll ("[name = 1err]")
Alert (c. length) // Error
Script