Created
June 30, 2013 18:14
-
-
Save vinaydotblog/5896240 to your computer and use it in GitHub Desktop.
Script to give typing effect to the given string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Document</title> | |
| <style> | |
| body { background: #f6f6f6; } | |
| textarea { width: 100%; border: 1px inset #ddd; padding: 5px; font-family: sans-serif; background: #f9f9f9; } | |
| textarea:focus { outline: 2px solid #25547b; border-radius: 5px; } | |
| </style> | |
| </head> | |
| <body> | |
| <textarea name="" style="width: 100%;" id="" cols="30" rows="10"></textarea> | |
| <script> | |
| var tmp = '', text = 'My Name is Vinay Aggarwal.', count =0, ta = document.querySelector('textarea'); | |
| var timer = setInterval(function(){ | |
| if( !text[count] ){ clearInterval(timer); } | |
| ta.value = tmp; | |
| tmp += text[count++]; | |
| }, 100); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment