943,513 Members | Top Members by Rank

Ad:
Jan 31st, 2009
0

Javascript Opcaity OnMouseOver

Expand Post »
How do I animate an image to fade in when I roll my mouse over a <div> and fade out when I move my mouse away. So far this is what I have. It doesn't seem to work well. Please help me, thanks.

Javascript
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2.  
  3. var homebutton = document.homebtn.style.opacity;
  4. var portfoliobutton = document.getElementById("portfolioimg");
  5. var linkbutton = document.getElementById("linkimg");
  6. var aboutbutton = document.getElementById("aboutimg");
  7.  
  8. function home_on(){
  9. document.homebtn.style.opacity = document.homebtn.style.opacity + 0.1;
  10. }
  11. function home_off(){
  12. document.homebtn.style.opacity = document.homebtn.style.opacity - 0.1;
  13. }
  14. </script>

HTML
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div id="homebg" onmouseover="home_on()" onmouseout="home_off()"><img name="homebtn" style="opacity: 0;" src="Home-On.png" alt="Home Button Image" /></div>
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Agent Cosmic is offline Offline
51 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: setAttribute and IE7
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: AJAX dropdown + PHP + MySQL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC