From d971a5903bab0d80091fd00b39f27bb345dc2045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Netto?= Date: Thu, 11 Jul 2013 13:02:32 -0300 Subject: [PATCH 1/3] Added typer ability to form inputs --- README.md | 1 + src/jquery.typer.js | 15 +++++++++------ test.html | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3be0145..4ab42ce 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ If you just want to use the effect once, use `typeTo()`. It can be used as follo ```javascript $('h3').typeTo("New Text"); +$('input#text').typeTo("New Text"); ``` This will do a one-time transition. diff --git a/src/jquery.typer.js b/src/jquery.typer.js index 9c59e25..fc185df 100644 --- a/src/jquery.typer.js +++ b/src/jquery.typer.js @@ -77,12 +77,15 @@ String.prototype.rightChars = function(n){ return; } - - $e.text( - oldLeft + - text.charAt(0) + - oldRight - ); + $e[0].tagName == "INPUT" ? $e.val( + oldLeft + + text.charAt(0) + + oldRight + ) : $e.text( + oldLeft + + text.charAt(0) + + oldRight + ); $e.data('oldLeft', oldLeft + text.charAt(0)); $e.data('text', text.substring(1)); diff --git a/test.html b/test.html index a9311f0..836439c 100644 --- a/test.html +++ b/test.html @@ -11,6 +11,8 @@

Welcome

+ + - + +

Hello, World!