Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-27-2009, 11:36 PM   PM User | #1
AntiHero118
New Coder

 
Join Date: Mar 2009
Location: Boston
Posts: 25
Thanks: 4
Thanked 0 Times in 0 Posts
AntiHero118 is an unknown quantity at this point
Exclamation jQuery image hover issues

Hello All,

I'm using a small script running through jQuery framework to do image rollovers for a overly complex tabbed nav, I'm using:

Code:
$(document).ready( function()
{
   PEPS.rollover.init();
});

PEPS = {};

PEPS.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".ro").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_o\./, '.');
   }
};
I need to get this to change a second image using a different class, so when one tab gets highlighted, the other one changes back to it's non-highlighted state.

Any help would be greatly appreciated!

Thanks

- AntiHero
AntiHero118 is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, jquery, nav, rollover

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:03 PM.


Advertisement
Log in to turn off these ads.