Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 2 additions & 6 deletions src/jquery.typer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
Expand Down
8 changes: 6 additions & 2 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
<html>
<head>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/src/jquery.typer.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="src/jquery.typer.js"></script>
<body>

<h1>Hello, World!</h1>
<h2 data-typer-targets="Hello,Hi,Hola,Hallo,Haai,Ola,Kaixo,Moni,Aloha,Bonjour,Ciao,Hej">Welcome</h2>

<h2 data-typer-targets="abcdefgfedcba,afgfa">Welcome</h2>

<input type="text" data-typer-targets="type your username here, tell me your username" />
<br/ >
<textarea data-typer-targets="write your message here"></textarea>

<script>
$(function () {
$('[data-typer-targets]').typer();
Expand Down