Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How to simulate typing using jQuery?

Posted on 2011-09-11
Last Modified: 2012-08-13
I have a div in html:

Open in new window

I just want the characters to appear one at a time from left to right. I'm using VWD. I thought the easiest way to do it was by usig jQuery but I'm open to suggestions.
Question by:WhyDidntItWork
LVL 82

Accepted Solution

leakim971 earned 500 total points
ID: 36520311
Test page : http://jsfiddle.net/CuhCK/
var s = "1234567890".split("");

var t = setInterval(function() {

    // get the next char from s, remove it from s, and append it to the current content       
    document.getElementById("one_at_time").innerHTML += s.shift();
    // or with jQuery :
    //$("#one_at_time").html( $("#one_at_time").html() + s.shift() );

    // if there's no more char to display stop the timer
    if(s.length==0) clearInterval(t);

}, 1000); // each 1s (1000ms)

Open in new window

<div id="one_at_time"></div>

Open in new window


Author Closing Comment

ID: 36520636
It's beautiful. It's a work of art.

Thanks for aching me about the split and shift methods.

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Placeholder text not disappearing in Contact Form 7 2 23
Index on a Table 6 25
Search Item in Table 2 19
Visual Studio npm 1 11
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question