how to use javascript to change div backgroundColor

Posted by lanqy on Stack Overflow See other posts from Stack Overflow or by lanqy
Published on 2009-12-09T15:16:56Z Indexed on 2010/04/08 3:13 UTC
Read the original article Hit count: 225

The html below:

<div id="catestory">

  <div class="content">
     <h2>some title here</h2>
      <p>some content here</p>
  </div>

  <div class="content">
     <h2>some title here</h2>
      <p>some content here</p>
  </div>

  <div class="content">
     <h2>some title here</h2>
      <p>some content here</p>
  </div>

</div>

when mouseover the content of div then it's backgroundColor and the h2(inside this div) backgroundColor change(just like the css :hover)

I know this can use css (:hover) to do this in modern browser but IE6 does't work

how to use javascript(not jquery or other js framework) to do this?

Edit:how to change the h2 backgroundColor too

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about change