www.webdeveloper.com
Results 1 to 2 of 2

Thread: Java Script text Display Deplay

  1. #1
    Join Date
    Aug 2007
    Posts
    1

    Java Script text Display Deplay

    Members I am new in Javacript, I want something like I have to write some lines of text on a webpage but i want the text to appear like its being typed. Like I am typing this messege now. It should appear as text on the page in some table or paragraph.

    Help Plz
    Aloha

  2. #2
    Join Date
    Mar 2005
    Posts
    767
    Code:
    <script src="http://code.jquery.com/jquery-1.1.3.1.min.js"></script>
    <script>
    $(function ($) {
        var output = $("#output")
        var message = output.text()
        output.empty()
        var currentChar = 0
        var interval = setInterval(function () {
            output.text(message.slice(0, ++currentChar))
            if (currentChar == message.length)
                clearInterval(interval)
        }, 140)
    })
    </script>
    
    <div id="output">Members I am new in Javacript, I want something like I have to write
    some lines of text on a webpage but i want the text to appear like its being typed.
    Like I am typing this messege now. It should appear as text on the page in some table or paragraph.
    
    Help Plz
    Aloha</div>
    Copy & paste the two script tags, put your message where you want it on your page in some containing element and give that element an id="output" attribute. To adjust the typing speed, replace the 140 with some other number (smaller numbers mean faster typing).
    Stop thinking, start drinking.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles