Home >Web Front-end >JS Tutorial >JS dynamically obtain node code innerHTML analysis [IE, FF]_javascript skills

JS dynamically obtain node code innerHTML analysis [IE, FF]_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:40:431193browse

child




When adding default attributes for child nodes:
childNode.className = "childClass" ; Or: childNode.className = new String("childClass"); parentNode.innerHTML IE and FF can both obtain [ child
]

when adding private attributes to child nodes :
childNode.type = "childType"; parentNode.innerHTML If and only if IE can obtain [ child
]
childNode.type = new String("childType"); / /Object object parentNode.innerHTML IE, FF cannot obtain [ child
]

childNode.setAttribute("type", "childType"); parentNode.innerHTML IE , FF can get [ child
]
childNode.setAttribute("type", new String("childType")); parentNode.innerHTML if and only if FF can get [ child
]

Get innerHTML after dynamically adding private attributes to the element. If you use .property method to assign the value, FireFox cannot obtain it no matter which data type it is. If the assigned type is an object, IE cannot. Obtained through innerHTML.
If you use the setAttribute method to assign a value, FireFox can obtain it regardless of the data type. If the assigned type is an object, IE cannot obtain it. Summary: In the IE environment, when the assignment type is an object, innerHTML cannot obtain its changes, and in the FireFox environment, the .property method cannot obtain its changes.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn