Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form>
- <input type="text" id="user-todo" placeholder="input" required>
- </form>
- <p>
- <span id="text-container">
- </span>
- </p>
- <script>
- document.getElementById("user-todo").addEventListener("keypress", function addLi(event) {
- if (event.keyCode === 13) {
- event.preventDefault();
- var input = document.getElementById("user-todo").value;
- document.getElementById("text-container").innerHTML = input;
- input = input.split();
- fontcolor =["blue","red","green","yellow","orange"]
- window.setInterval(
- for(var i =0;i<input.length,i++){
- document.getElementById("text-container").innerHTML=document.getElementById("text-container").innerHTML.replace(input[i],'<span style="'+color: fontcolor[Math.floor(Math.random() * 5)];+'">'+input[i]+'</span>');
- },1000);
- }
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement