< title>setAttribute('class', 'abc')
test div
<script> <br>var div = document.getElementById('d1'); <br>div.setAttribute("class", "abc"); <br></script>
< /HTML>
Result: IE6/ 7 does not support the setAttribute('class',xxx) method to set the class of an element.
setAttribute('className', 'abc') test div
<script> <br>var div = document.getElementById('d1'); <br>div.setAttribute("className", "abc"); <br></script>
Result: IE8/9/10/Firefox/Safari/Chrome/Opera does not support the setAttribute('className',xxx) method to set the class of an element.
It’s interesting that when using setAttribute, the first parameters are class and className. The situation is exactly the opposite in IE6/7 and IE8/9/10/Firefox/Safari/Chrome/Opera.