Tuesday, March 15, 2011

Blinking text using jquery

Hi,

The following code is to blink the text using jquery


<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>

<div id="msg"> <strong><font color="red">Awesome Gallery By Anil Labs</font></strong></p> </div>

<script type="text/javascript" >
function blink(selector){
$(selector).fadeOut('slow', function(){
$(this).fadeIn('slow', function(){
blink(this);
});
});
}

blink('#msg');
</script>

24 comments:

  1. Works perfectly! Exactly the thing I wanted, only need to modify the effect. Thanx a lot!

    ReplyDelete
  2. Tis' cool but doesn't work in Safari :)

    ReplyDelete
  3. Should remove the extra backslash on the end of "<script text=..".

    ReplyDelete
  4. Thanks for acript
    Nice one

    ReplyDelete
  5. THANKS WORKING WELL

    ReplyDelete
  6. but its not working when we put the div in the body why???

    ReplyDelete
  7. Dear Anonymous, if you want to but the div at the body, then instead of blink('#msg'); , add the following code :

    jQuery(document).ready(function() {
    blink('#msg');
    });


    The thing is that you are trying to call div #msg at the head section and it does not exist yet as it is at the body tag, my code will call the div after the entire page load.

    Thanks Anil...

    ReplyDelete
  8. how to stop the function after certain time

    ReplyDelete
  9. setInterval(function() {
    jQuery('.blink').fadeOut('slow', function(){
    jQuery(this).fadeIn('slow');
    });
    }, 5000);

    ReplyDelete
  10. hii this is kriti and i am having a query...
    How to search a string for a specified value, and returns the text of the found value and to blink it?

    ReplyDelete
  11. How to blink a particular letter in the word using jquery ?
    For example :-

    Word is :- Awesome
    letter to blink is :- s

    Please suggest possible solutions .

    Thanks in advance.

    ReplyDelete
  12. kriti: i am also having the same query.

    ReplyDelete
  13. This works. Thanks Anil and keep up the good work!!

    ReplyDelete
  14. Recursive calling the method (blink) without return.is it correct?

    ReplyDelete
  15. Or simply:

    function blink(selector) {
    $(selector).fadeToggle('slow', function(){ blink(this); });
    }

    ReplyDelete
  16. hai am doing a project using html n jsp as a fresher i am not getting much idea plz help me frnd , n dis s my id aishukutty2@gmail.com plz within in today ..........))))))))))

    ReplyDelete
  17. Thanks i benefited so much from this post. How do i make it blink a bit more slower. Pls email me at cryswen@gmail.com. i am most grateful. Welldone friend.

    ReplyDelete
  18. Would a recursive approach like this fill up the call stack?

    ReplyDelete