How to match the word in jquery

Posted by Mirage on Stack Overflow See other posts from Stack Overflow or by Mirage
Published on 2010-05-12T02:54:20Z Indexed on 2010/05/12 3:04 UTC
Read the original article Hit count: 204

Filed under:

I have the image and i am fade in and fade out the image on click. But i want that if the same is present then it should not fadein/fadeout.

My jquery code is

 switch(current_id)
                {

                    case 'l1':
                        $("#left_img img").fadeOut(500, function() {
                        $(this).attr("src","rrr.gif").load( function() {
                        $(this).fadeIn(500);
                                });
                                });
                    break;

                    case 'l3':
                        $("#left_img img").fadeOut(500, function() {
                        $(this).attr("src","cc1.gif").load( function() {
                        $(this).fadeIn(500);
                                });
                                });
                break;  

If i click on link 1 then image A appears with fade effect. but if i click again link 1 agan , then again i see fade effect . Is there any way i can avoid that if same link is clicked again

© Stack Overflow or respective owner

Related posts about jQuery