Is it possible to make an image blink using jquery – i.e fade to a lighter colour and back within a few seconds and loop? Just wondering if theres an alternative to using Flash for this?
Cheers
Paul
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’d suggest binding a custom “fadeToggle” event to your image and swapping between effects based on a value you save to the jQuery data store for the image, then triggering the event recursively in the completion callback of each animation. This has the benefit of simply unbinding the event if you want to stop the animation.
For instance:
See a working fiddle here.
EDIT:
After happening across some jQuery 1.4.4 changelogs, I noticed the .fadeToggle() function, which makes this even easier. The sample code is below. It basically consists of the exact same model of triggering a fadeToggle event repeatedly in the callback of the new fadeToggle animation.
The fiddle has been updated with the new code.