Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Created June 7, 2011 08:25
Show Gist options
  • Save jdlrobson/1011894 to your computer and use it in GitHub Desktop.
Save jdlrobson/1011894 to your computer and use it in GitHub Desktop.
Takes a textarea/input and deletes the text bit by bit
function clear(el) {
var interval = 300;
var charactersToRemove = 1;
var id = setInterval(function(ev) {
var x = $(el).val();
if(!x) {
clearInterval(id);
} else {
var pos = x.length - charactersToRemove;
x = x.substr(0, pos);
$(el).val(x);
charactersToRemove *= 2
}
}, interval);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment