Home >Web Front-end >JS Tutorial >setAttribute and class conflict resolution_javascript skills

setAttribute and class conflict resolution_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:06:121145browse

Suppose we want to use setAttribute to change a dom class, how should we write it?
1. setAttribute("class","red")
2. setAttribute("className","red")

The answer is:
Option 1. Use under firefox
Option 2. Use

under IE. If you setAttribute("class") to DOM under IE and use IE Developer to look at the structure, you will find that two classes are displayed on the DOM... It turns out that IE is the Custom classes are distinguished from system classes. - -b

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