A couple things..

1. The click function can't be used to fadeIn the image again...
because you wouldn't be able to click on it when it's hidden

2. Do you want a single click to cause the fadeOut-fadeIn-fadeOut-
fadeIn? If so, you could use the callback functions of the fadeIn and
fadeOut transitions:

$(document).ready(function(){
    $('img.twitter).click(function(){
        $(this).fadeOut('fast', function(){
            $(this).fadeIn('fast',function(){
                $(this).fadeOut('fast', function(){
                    $(this).fadeIn('fast');
                });
            });
        });
    });
});

The callback function runs when the transition is complete.


On Sep 16, 8:36 pm, Galaxy Man <galaxyma...@googlemail.com> wrote:
> Hi guys.. this is the first time I use Jquery Directly & with my hands
> purely.. I wrote this code:
> $("img.twitter").click(function(){
>
> $("img.twitter").fadeOut("fast");
>
> });
>
> $("img.twitter").click(function(){
>
> $("img.twitter").fadeIn("fast");
>
> });
>
> $("img.twitter").click(function(){
>
> $("img.twitter").fadeOut("fast");
>
> });
>
> $("img.twitter").click(function(){
>
> $("img.twitter").fadeIn("fast");
>
> });
>
> I want an image with the class twitter to fade in& out twice.. but it
> doesn't work.. when I tried to replace it with this:
> $(document).click(function(){
>
> $("img.twitter").fadeOut("fast");
>
> });
>
> $(document).click(function(){
>
> $("img.twitter").fadeIn("fast");
>
> });
>
> $(document).click(function(){
>
> $("img.twitter").fadeOut("fast");
>
> });
>
> $(document).click(function(){
>
> $("img.twitter").fadeIn("fast");
>
> });
>
> it works but when when clicking on any place on the page, I don't need
> it like that, I need it only on the image.. what is the wrong in that?

Reply via email to