Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to change styles on onload=

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34348
    cnwtx
    Member

    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';"
    #87190
    jamygolden
    Member
    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:

    #87191
    richtestani
    Member

    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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.