Grow your CSS skills. Land your dream job.

How to change styles on onload=

  • # September 14, 2011 at 1:15 pm

    I know this is a stupid question that I should know, but how do you change two style rules for the same element at one time on onload? I have this, but I want to add opacity:0; to it.


    onload="javascript:document.getElementById('loader').style.visibility='hidden';"
    # September 14, 2011 at 2:22 pm
    onload="javascript:document.getElementById('loader').style.visibility='hidden';document.getElementById('loader').style.opacity='0';"

    That should work.

    It would be better not to mix HTML with javascript like that though. Try this instead:

    # September 14, 2011 at 2:25 pm

    put it into a function



    window.onload = pre_loader;

    function pre_loader() {
    javascript:document.getElementById('loader').style.visibility='hidden';
    javascript:document.getElementById('loader').style.opacity=0;

    }

    I don’t think IE support opacity though.

    # September 14, 2011 at 2:54 pm

    Thank You!!!!
    -Cliff

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".