$(function(){
       $("img").hover(
                function(){
                src = $(this).attr("src");
                        var newSrc = src.replace(/.png/, "-hover.png");
                        $(this).attr("src",newSrc);
                },
                function(){
                        var newSrc = src.replace(/-hover.png/, ".png");
                        $(this).attr("src",src);
                }
        );
});

This is untested and certainly not the best way to do this (like I said 
earlier). You should be using CSS for image rollovers.


Teddy wrote:
I mean not like that...

I mean what ever the src value I want to add hover when it hover....
and when mouse out I want delete that hover..

<img alt="My Account" src="/images/whatever.png"/>

and when hover that image I want became like this

<img alt="My Account" src="/images/whatever-hover.png"/>

and when mouse out that image became
<img alt="My Account" src="/images/whatever.png"/>


On Sep 28, 9:38 pm, Liam Potter <radioactiv...@gmail.com> wrote:
$(function(){
        $("img").bind("mouseover",function(){
                $(this).attr("src","/images/menu-my-account-hover.png");
        });

});

but this is the worst way you can do rollovers. You should be doing this in 
pure CSS, and the best way would be to use an image sprite.

Teddy Hong wrote:
If I have a tag image like this..
<img alt="My Account" src="/images/menu-my-account.png"/> and when hover that image I want became like this <img alt="My Account" src="/images/menu-my-account-hover.png"/> How to code this with jquery? Thanks....

Reply via email to