setAttribute(‘class’) and IE

What happens on IE, our favorite browser, when you try to setup a class attribute on a DOM element? Actually this is not possible, because setAttribute(‘class’, ‘my-class’) is obviously working only on non-IE browsers.

On IE actually you should setup the class on an element with that structure:

element.setAttribute('className', 'my-class');

Related posts:

  1. CSS Priority: The Difference Between a.my-class and .my-class
  2. cssText and how it can be very very useful
  3. Friday Algorithms: A Data Structure: JavaScript Stack
This entry was posted in javascript, micro tutorial and tagged , , , . Bookmark the permalink.

One Response to setAttribute(‘class’) and IE

  1. Maks says:

    Сайт отличный. Надо бы Вам награду вручить за него или просто почетный орден. =)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">