Javascript: Changing Class Names Issue on IE

IE has issue to change the class of an element using java scrip
   var currentTag = document.getElementById(tagID);
   currentTag.setAttribute("class", "stlyeclass");
this does not work on IE and the work around for the same is
use setAttribute("className", "stlyeclass") instead of setAttribute("class", "stlyeclass");
But funny thing is that it will stop working on fire fox. So to make code cross browser use both some thing demonstrated below:

function changeCSS(tagID)
   var currentTag = document.getElementById(tagID);
   currentTag.setAttribute("class", "secondClass");
   currentTag.setAttribute("className", "secondClass");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.