When using the name attribute to obtain the dom element under the IE8 browser, it is not case-sensitive.
For example:
<input type='text' name='C1'/> <input type='text' name='c1'/>
There are two input boxes as above, their name attributes are uppercase C1 and lowercase c1 respectively
When getting elements, use jqury under Google Chrome to get:
$("input[name='c1']").length // 1
The DOM element obtained when the above code is run under I8 is 2.
Change to js native method to obtain:
document.getElementsByName('c1').length document.querySelectorAll("input[name='c1").length
The above two methods are both 2 under IE8. It can be seen that the name attribute under IE8 is not case-sensitive.
When encountering these problems, we can add its parent element to distinguish the selection when selecting the dom element:
<p class='p1'><input type='text' name='C1'/></p> <p class='p2'><input type='text' name='c1'/></p> document.querySelectorAll(".p1 input[name='C1") document.querySelectorAll(".p2 input[name='c1")
This solves the problem that IE8 cannot distinguish the case of the name attribute. question.
The above is the detailed content of How to solve the problem that the DOM element does not distinguish the case of the name attribute under the IE8 browser. For more information, please follow other related articles on the PHP Chinese website!