Thursday, September 10, 2009

Changing HTML class attributes using Javascript

If you try to change the HTML class of an object on the fly using javascript, you might find that it works on Firefox but doesn't work with Internet Explorer. In that case, you're probably doing this:
document.getElementById("myObject").class = "newclass";
However, after being ready to bang my head on the desk for two days and doing a binary search on 500+ subversion revisions to find the exact working/non-working combo for IE, I have discovered this. You ought to use
document.getElementById("myObject").className = "newclass";
Heh... the joys of life.

2 comments:

  1. As you have written Changing HTML class attributes using Javascript.I totally agree with you.If we try to change the HTML class of an object on the fly using javascript, we might find that it works on Firefox but doesn't work with Internet Explorer. In that case,we are probably doing this:

    document.getElementById("myObject").class = "newclass";

    I really liked your blog.
    digital signature Adobe Reader

    ReplyDelete
  2. Do you need to increase your credit score?
    Do you intend to upgrade your school grade?
    Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
    Do you need any information concerning any database.
    Do you need to retrieve deleted files?
    Do you need to clear your criminal records or DMV?
    Do you want to remove any site or link from any blog?
    you should contact this hacker, he is reliable and good at the hack jobs..
    contact : cybergoldenhacker at gmail dot com

    ReplyDelete