Hey, guys.,, I am in 12th class and I was a given a question in my computer practical exam to write a script in javascript that changes background color of the webpage when mouse cursor is over the link of the particular color. For eg. We created a link naming red and when we put our mouse cursor over that link, the background color changes to red instead of white. And further I was asked that if we move the cursor from that link the background color should again change to white from red. Help me friends.... the first scritp I wrote but after moving the cursor from that link it still remains red only, I mean the background of the webpage. Help guys.. Thanks
Hi, You can check this HTML: <script language="javascript"> function change_background_color(c){ document.getElementById('div2change').style.backgroundColor= '#'+c; } </script> <div id="div2change" style="background-color: #cde; padding: 10px ; text-align: center;"> You can change background color of this div just bringing your mouse over colors. <a style="background-color: #0f3;" class="cc" onMouseOver="change_background_color('00ff33'); ">00ff33</a> <a style="background-color: #6cf;" class="cc" onMouseOver="change_background_color('66ccff'); ">66ccff</a> <a style="background-color: #ff9;" class="cc" onMouseOver="change_background_color('ffff99'); ">ffff99</a> <a style="background-color: #0fc;" class="cc" onMouseOver="change_background_color('00ffcc'); ">00ffcc</a> </div> Thanks