Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    60
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Div containers changing background color when hovering over them?

    What I am trying to achieve is this:
    http://www.pageresource.com/dhtml/jtut6.htm
    Except with div containers rather than tables

    Can that be achieved?
    If so, how?
    Could you link me to some tutorials?
    Last edited by brownleaf; 08-24-2008 at 05:04 AM.

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your link does not work. Repost so that we may see what you are trying to achieve

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    60
    Thanks
    6
    Thanked 0 Times in 0 Posts

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Code:
    <script type="text/javascript">
    window.onload=function(){
    var el=document.getElementById('el');
    el.onmouseover=function(){this.style.backgroundColor='#9c0';}
    el.onmouseout=function(){this.style.backgroundColor='#eee';}
    }
    </script>
    <div id="el" style="background-color:#eee;">
    I'm a div
    </div>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    60
    Thanks
    6
    Thanked 0 Times in 0 Posts
    ^
    When I do that, the top and bottom part of the div container doesn't change color, only the middle strip. Also, it does not work in firefox.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •