How to change color of <select>?

H

html

Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgColor ="blue" ;
but how do I do this for the select tags?
....and I prefer it to apply to all select tags
Tia.
 
S

SAM

Le 9/27/08 2:24 AM, html a écrit :
Hello all,

I need to change the colour of my text. For the paragraph I do
document.fgColor ="blue" ;

prefer
JS :
document.getElementById('P_1').style.background = 'skyblue';
HTML :
but how do I do this for the select tags?

<select style="background: orange">
<option>100
<option>200
<option style="background: yellow">300
<option>400
...and I prefer it to apply to all select tags

<style type="text/css">
select { background: yellow; border: 2px solid orange; }
option { background: #ffc }
p { background: #ddd; }
#P_1 { background: azure; color: blue; text-align: justify }
</style>
<p>
<select>
<option>100
<option>200
<option style="background: yellow">300
<option>400
</select>
</p>
<p id="P_1"> re blah </p>

<http://www.w3.org/TR/CSS21/indexlist.html>
 
H

html

Hello all,
prefer
JS :
document.getElementById('P_1').style.background = 'skyblue';
HTML :


<select style="background: orange">
<option>100
<option>200
<option style="background: yellow">300
<option>400


<style type="text/css">
select { background: yellow; border: 2px solid orange; }
option { background: #ffc }
p { background: #ddd; }
#P_1 { background: azure; color: blue; text-align: justify }
</style>
<p>
<select>
<option>100
<option>200
<option style="background: yellow">300
<option>400
</select>
</p>
<p id="P_1"> re blah </p>

<http://www.w3.org/TR/CSS21/indexlist.html>

Thank you, what I need is a little different.

First of all, it is interesting that document.fgcolor propagates into
paragraphs but not into select elements, any idea why?

Second, I want to be able to change the colour of the select
tags as a response to a click on a button, so how do I assign
to all select tags a colour in script (as opposed to in style sheet/tag)?
Tia
 
D

dhtml

html said:
Thank you, what I need is a little different.

First of all, it is interesting that document.fgcolor propagates into
paragraphs but not into select elements, any idea why?
It does not do that.

It only looks like it does that. Default background color is transparent.
Second, I want to be able to change the colour of the select
tags as a response to a click on a button, so how do I assign
to all select tags a colour in script (as opposed to in style sheet/tag)?

Change a class selector in an element above them. For example, add a
class "detonate" to body.

<style type="text/css">
..detonated select {
background: chartreuse;
}
</style>

using:

<button onclick="document.body.className='detonated'">detonate</button>


Garrett
 
D

dhtml

html said:
Thank you, what I need is a little different.

First of all, it is interesting that document.fgcolor propagates into
paragraphs but not into select elements, any idea why?
It does not do that.

It only looks like it does that. Default background color is transparent.
Second, I want to be able to change the colour of the select
tags as a response to a click on a button, so how do I assign
to all select tags a colour in script (as opposed to in style sheet/tag)?

Change a class selector in an element above them. For example, add a
class "detonate" to body.

<style type="text/css">
..detonated select {
background: chartreuse;
}
</style>

using:

<button onclick="document.body.className='detonated'">detonate</button>


Garrett
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top