How to create blinking effect in JQuery?

Here we created a simple function "Blink". It required two parameters. One is the element object and other is the blinking speed. You will have to include jQuery library. In this example the blink() function is used for to blink the span element. jQuery animate() method is the main part of this function.

<script>
function Blink(Element,Speed)
{
    Element.animate({opacity: 0.2},Speed,function()
    {
    Element.animate({opacity: 1.0},Speed,function()
        {
        Blink(Element,Speed);
        });
});
}
$(document).ready(function()
{
Blink($(".Warning"),200); //400 = Blinking Speed
});
</script>
Final code and demo is here


Demo

No comments:

Post a Comment