Return button Style to Default

Discussion in 'Javascript' started by Rick Brandt, Mar 6, 2006.

  1. Rick Brandt

    Rick Brandt Guest

    I am using some buttons to hide/show various divs and am changing the style of
    the button to indicate which button's view is "active".

    My problem is that for the non-active buttons I want the default look. Once I
    change a button's style to something else what is the style setting to revert
    them back to this default?

    EX:
    Button starts at default.

    Upon press set different background
    document.getElementById("btnName").style.background = "someColor"

    What command changes it back? I've tried "" and that seems to work (you guessed
    it) in FF, but not in IE. I also tried ThreeDFace with the same effect (good in
    FF, bad in IE).

    TIA
     
    Rick Brandt, Mar 6, 2006
    #1
    1. Advertising

  2. Rick Brandt

    RobG Guest

    Rick Brandt wrote:
    > I am using some buttons to hide/show various divs and am changing the style of
    > the button to indicate which button's view is "active".
    >
    > My problem is that for the non-active buttons I want the default look. Once I
    > change a button's style to something else what is the style setting to revert
    > them back to this default?
    >
    > EX:
    > Button starts at default.
    >
    > Upon press set different background
    > document.getElementById("btnName").style.background = "someColor"


    Changing the style object's *backgroundColor* property between 'red' and
    '' seems to work fine for me in IE 6.

    <button id="btn"
    onclick="alert(this.style.backgroundColor);">button</button>
    <button
    onclick="document.getElementById('btn').style.backgroundColor = 'red';"
    >Make it red</button>

    <button
    onclick="document.getElementById('btn').style.backgroundColor = '';"
    >Revert to default</button>





    This is more a CSS question, it may be better answered in
    news:comp.infosystems.www.authoring.stylesheets



    --
    Rob
     
    RobG, Mar 6, 2006
    #2
    1. Advertising

  3. Rick Brandt

    Rick Brandt Guest

    "RobG" <> wrote in message
    news:_YMOf.614$...
    > Rick Brandt wrote:
    >> I am using some buttons to hide/show various divs and am changing the style
    >> of the button to indicate which button's view is "active".
    >>
    >> My problem is that for the non-active buttons I want the default look. Once
    >> I change a button's style to something else what is the style setting to
    >> revert them back to this default?
    >>
    >> EX:
    >> Button starts at default.
    >>
    >> Upon press set different background
    >> document.getElementById("btnName").style.background = "someColor"

    >
    > Changing the style object's *backgroundColor* property between 'red' and ''
    > seems to work fine for me in IE 6.
    >
    > <button id="btn"
    > onclick="alert(this.style.backgroundColor);">button</button>
    > <button
    > onclick="document.getElementById('btn').style.backgroundColor = 'red';"
    > >Make it red</button>

    > <button
    > onclick="document.getElementById('btn').style.backgroundColor = '';"
    > >Revert to default</button>


    Thanks, I'll check recheck, but I could have sworn that when I first tried
    backgroundColor I got errors. Maybe I had the case wrong? Does the case have
    to be just as you have it?

    > This is more a CSS question, it may be better answered in
    > news:comp.infosystems.www.authoring.stylesheets


    Yeah, but since it was about setting the style in js I figured they would just
    send me here : )

    Thanks again.
     
    Rick Brandt, Mar 6, 2006
    #3
  4. Rick Brandt

    RobG Guest

    Rick Brandt wrote:
    > "RobG" <> wrote in message
    > news:_YMOf.614$...

    [...]
    >
    > Thanks, I'll check recheck, but I could have sworn that when I first tried
    > backgroundColor I got errors. Maybe I had the case wrong? Does the case have
    > to be just as you have it?


    Yes. HTML isn't case sensitive (in general) but JavaScript is.


    >>This is more a CSS question, it may be better answered in
    >>news:comp.infosystems.www.authoring.stylesheets

    >
    >
    > Yeah, but since it was about setting the style in js I figured they would just
    > send me here : )


    Your issue actually is with JavaScript, but there you may have received
    more (authoritative) information about using styles with buttons (or
    not...). :)


    --
    Rob
     
    RobG, Mar 6, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Nicholson
    Replies:
    3
    Views:
    749
    Rob Nicholson
    May 28, 2005
  2. Andrew Crowe
    Replies:
    2
    Views:
    16,274
    Jukka K. Korpela
    Feb 6, 2004
  3. AlecL
    Replies:
    2
    Views:
    824
    Alexey Smirnov
    Feb 12, 2007
  4. Greenhorn
    Replies:
    15
    Views:
    831
    Keith Thompson
    Mar 6, 2005
  5. Ken Varn
    Replies:
    0
    Views:
    472
    Ken Varn
    Apr 26, 2004
Loading...

Share This Page