Skip to content

Instantly share code, notes, and snippets.

@emersonbroga
Forked from anonymous/index.html
Created August 8, 2017 06:42
Show Gist options
  • Save emersonbroga/bd75610ae139318a456204ceec512ac0 to your computer and use it in GitHub Desktop.
Save emersonbroga/bd75610ae139318a456204ceec512ac0 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
input {
height: 30px;
width: 50%;
padding: 5px;
font-size: 20px;
}
</style>
</head>
<body>
<input id="test" value"" placeholder=""/>
<script id="jsbin-javascript">
var placeholder = 'Awesome';
var element = document.getElementById('test');
function animate(element, speed, text, lenght, wait){
setTimeout(function(){
var placeholder = text.slice(0, lenght);
element.placeholder = (lenght % 2 === 0) ? placeholder : placeholder + "|";
if (text.length > lenght){
animate(element, speed, text, lenght + 1, wait);
return;
}
}, speed);
}
animate(element, 200, placeholder, 0, 10);
</script>
<script id="jsbin-source-css" type="text/css">input {
height: 30px;
width: 50%;
padding: 5px;
font-size: 20px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var placeholder = 'Awesome';
var element = document.getElementById('test');
function animate(element, speed, text, lenght, wait){
setTimeout(function(){
var placeholder = text.slice(0, lenght);
element.placeholder = (lenght % 2 === 0) ? placeholder : placeholder + "|";
if (text.length > lenght){
animate(element, speed, text, lenght + 1, wait);
return;
}
}, speed);
}
animate(element, 200, placeholder, 0, 10);
</script></body>
</html>
input {
height: 30px;
width: 50%;
padding: 5px;
font-size: 20px;
}
var placeholder = 'Awesome';
var element = document.getElementById('test');
function animate(element, speed, text, lenght, wait){
setTimeout(function(){
var placeholder = text.slice(0, lenght);
element.placeholder = (lenght % 2 === 0) ? placeholder : placeholder + "|";
if (text.length > lenght){
animate(element, speed, text, lenght + 1, wait);
return;
}
}, speed);
}
animate(element, 200, placeholder, 0, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment