Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="blinkText"></div>
- <script>
- // Takes text to blink and id of element to blink text in
- function blinkText(text, id) {
- // Blink interval
- setInterval(blinker, 250);
- // Flag to see what state text is in (true or false)
- var flag = true;
- // Number of times to blink text
- var blinkNum = 50;
- var i = 1;
- //you can select whole div by ajax
- var divID = document.getElementById(id);
- function blinker() {
- if (i < blinkNum) {
- if (flag) {
- divID.innerHTML = text;
- flag = false;
- } else {
- divID.innerHTML = "";
- flag = true;
- }
- i++;
- } else {
- // Delete if still showing
- divID.innerHTML = "";
- // Stop blinking
- clearInterval(blinker);
- }
- }
- }
- blinkText("Hello World", "blinkText");
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement