Return button Style to Default

R

Rick Brandt

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
 
R

RobG

Rick said:
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
 
R

Rick Brandt

RobG said:
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';"
<button
onclick="document.getElementById('btn').style.backgroundColor = '';"

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.
 
R

RobG

Rick said:
news:[email protected]... [...]

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.

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...). :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top