943,169 Members | Top Members by Rank

Ad:
Aug 28th, 2010
0

Multiple image rollover

Expand Post »
Hi all. I've tried to make a simple hover effect about small images but it won't work.
I also tried to make the following script: 2 seconds after page loading image1 changes 2 seconds after that image1 returns to back state and image2 changes and etc. Can someone help? Best regards.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <style type="text/css">
  4. #as:hover{
  5. background-image: url(images/numr.png);
  6. }
  7. #ad:hover{
  8. background-image: url(images/numr.png);
  9. }
  10. #af:hover{
  11. background-image: url(images/numr.png);
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <input type="image" src="images/num1.png" id="as">
  17. <input type="image" src="images/num2.png" id="ad">
  18. <input type="image" src="images/num3.png" id="af">
  19. </body>
  20. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 6
Junior Poster in Training
george61 is offline Offline
59 posts
since Jul 2010
Aug 28th, 2010
0
Re: Multiple image rollover
That ":hover" will likely not be recognized by IE 6. There are a lot of users still using that browser. Try the following instead:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  4.  
  5. <script>
  6. //cache the images first
  7. var imgs=[];
  8. imgs[imgs.length]=new Image();
  9. imgs[imgs.length-1].src='images/numr.png';
  10.  
  11. imgs[imgs.length]=new Image();
  12. imgs[imgs.length-1].src='images/num1.png';
  13.  
  14. imgs[imgs.length]=new Image();
  15. imgs[imgs.length-1].src='images/num2.png';
  16.  
  17. imgs[imgs.length]=new Image();
  18. imgs[imgs.length-1].src='images/num3.png';
  19.  
  20. $(document).ready(function(){
  21. $('.imageButton').hover( hoverIn, hoverOut);
  22. });
  23.  
  24. function hoverIn(){
  25. $(this).attr('prevImage',$(this).attr('src')).attr('src','images/numr.png');
  26. }
  27. function hoverOut(){
  28. $(this).attr('src', $(this).attr('prevImage') ).attr('prevImage','');
  29. }
  30. </script>
  31. </head>
  32. <body>
  33. <input type="image" class="imageButton" src="images/num1.png" id="as">
  34. <input type="image" class="imageButton" src="images/num2.png" id="ad">
  35. <input type="image" class="imageButton" src="images/num3.png" id="af">
  36. </body>
  37. </html>
Reputation Points: 116
Solved Threads: 243
Veteran Poster
hielo is offline Offline
1,123 posts
since Dec 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: javascript cursor placement
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: how to write this kind of xpath exprssion?





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


Follow us on Twitter


© 2011 DaniWeb® LLC