How to change color of <select>?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • html

    #1

    How to change color of <select>?

    Hello all,

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


  • SAM

    #2
    Re: How to change color of &lt;select&g t;?

    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.fgColo r ="blue" ;
    prefer
    JS :
    document.getEle mentById('P_1') .style.backgrou nd = 'skyblue';
    HTML :
    <p id="P_1"blah </p>

    but how do I do this for the select tags?
    <select style="backgrou nd: orange">
    <option>100
    <option>200
    <option style="backgrou nd: yellow">300
    <option>400
    </select>
    ...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="backgrou nd: yellow">300
    <option>400
    </select>
    </p>
    <p id="P_1"re blah </p>

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

    --
    sm

    Comment

    • html

      #3
      Re: How to change color of &lt;select&g t;?

      Hello all,

      I need to change the colour of my text. For the paragraph I do
      document.fgColo r ="blue" ;
      >
      prefer
      JS :
      document.getEle mentById('P_1') .style.backgrou nd = 'skyblue';
      HTML :
      <p id="P_1"blah </p>
      >
      >
      but how do I do this for the select tags?
      >
      <select style="backgrou nd: orange">
      <option>100
      <option>200
      <option style="backgrou nd: yellow">300
      <option>400
      </select>
      >
      ...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="backgrou nd: 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.fgcolo r 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


      Comment

      • dhtml

        #4
        Re: How to change color of &lt;select&g t;?

        html wrote:
        >>Hello all,
        >>>
        >>I need to change the colour of my text. For the paragraph I do
        >>document.fgCo lor ="blue" ;
        >prefer
        >JS :
        >document.getEl ementById('P_1' ).style.backgro und = 'skyblue';
        >HTML :
        ><p id="P_1"blah </p>
        >>
        >>
        >>but how do I do this for the select tags?
        ><select style="backgrou nd: orange">
        > <option>100
        > <option>200
        > <option style="backgrou nd: yellow">300
        > <option>400
        ></select>
        >>
        >>...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="backgrou nd: 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.fgcolo r 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="docume nt.body.classNa me='detonated'" >detonate</button>


        Garrett
        Tia
        >
        >

        Comment

        • dhtml

          #5
          Re: How to change color of &lt;select&g t;?

          html wrote:
          >>Hello all,
          >>>
          >>I need to change the colour of my text. For the paragraph I do
          >>document.fgCo lor ="blue" ;
          >prefer
          >JS :
          >document.getEl ementById('P_1' ).style.backgro und = 'skyblue';
          >HTML :
          ><p id="P_1"blah </p>
          >>
          >>
          >>but how do I do this for the select tags?
          ><select style="backgrou nd: orange">
          > <option>100
          > <option>200
          > <option style="backgrou nd: yellow">300
          > <option>400
          ></select>
          >>
          >>...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="backgrou nd: 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.fgcolo r 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="docume nt.body.classNa me='detonated'" >detonate</button>


          Garrett
          Tia
          >
          >

          Comment

          Working...