"unsetting" style properties.

Discussion in 'CSS' started by hhalkin, Sep 13, 2007.

  1. #1
    Case 1:
    When I defined a class WITHOUT specifying "background-color" and create a div with that class, I obtain a tranparent object (I can see what is behind it).

    Case 2:
    When I defined a class WITH specifying "background-color" and create a div with that class, I obtain an opaque object of that color (I can NOT see what is behind it).

    In Case 2, if I use Javascript to dynamically change the backgroundColor of that div the expected thing happens: the color of the object changes to the new specified color.

    My question: Given a class as in Case 2 and given a div created with that class, how can I use Javascript to dynamically change that div to make it appear as a div produced by the class of Case 1?

    Thank you.
     
    hhalkin, Sep 13, 2007 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You mean you want js to turn the opaque coloured background of a div to transparent?

    If this is happening on :hover or other pseudo-classes, CSS alone can do it.
     
    Stomme poes, Sep 14, 2007 IP
  3. xemiterx

    xemiterx Peon

    Messages:
    62
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <script type="text/javascript">
    document.getElementById('divid').style.background = 'transparent';
    </script>
    
    HTML:
     
    xemiterx, Sep 14, 2007 IP
  4. hhalkin

    hhalkin Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you guys.

    The suggestion of xemiterx does the job.
    I did not understand the answer of Stomme_Poes.
     
    hhalkin, Sep 14, 2007 IP