Placeholder ticker
HTML
<input type="text" placeholder="enter some text here..." />
CSS
input{
padding: 5px;
border: 1px solid #ccc;
width: 80%;
}
body{
padding: 10px;
}
JavaScript
$('[placeholder]').each(function() {
var $ths = $(this),
scrpt = $ths.attr('placeholder') + ' ',
chr, str, reset = function() {
str = ' > ';
chr = 0;
},
set = function() {
if (scrpt[chr]) {
str += scrpt[chr++];
} else {
reset();
}
$ths.attr('placeholder', str);
},
tck = function() {
setTimeout(function() {
set();
tck();
}, 200);
};
reset();
set();
tck();
});