Home > Web Front-end > JS Tutorial > body text

setAttribute and class conflict resolution_javascript skills

WBOY
Release: 2016-05-16 19:06:12
Original
1078 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template