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 d1520cc..b382211 100644 --- a/src/jquery.typer.js +++ b/src/jquery.typer.js @@ -78,12 +78,8 @@ String.prototype.rightChars = function(n){ return; } - - $e.text( - oldLeft + - text.charAt(0) + - oldRight - ).data({ + var method = $e[0].tagName.match(/INPUT|TEXTAREA/) ? 'val' : 'text'; + $e[method](oldLeft + text.charAt(0) + oldRight).data({ oldLeft: oldLeft + text.charAt(0), text: text.substring(1) }); diff --git a/test.html b/test.html index a9311f0..91d9539 100644 --- a/test.html +++ b/test.html @@ -2,8 +2,8 @@ - - + +

Hello, World!

@@ -11,6 +11,10 @@

Welcome

+ +
+ +