Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:46:02+00:00 2026-06-18T09:46:02+00:00

I am trying to provide a simple way to get a typing text effect,

  • 0

I am trying to provide a simple way to get a typing text effect, but with the possibility to allow HTML tags too. I have some code that works, but I see the tags are being considered part of the text.

For example, if The text is "Anyone is <b>awesome</b>, I see the following when it reaches the bold part:

<
<b
<b>
<b>a
<b>aw
<b>awe
<b>awes
<b>aweso
<b>awesom
<b>awesome
<b>awesome<
<b>awesome</
<b>awesome</b
<b>awesome</b>

How can I skip html nodes without removing them from string? I want to keep the formatting working.

Here’s what I’ve done so far:

<div id="foo"></div>

$.fn.typer = function (text, options) {
    options = $.extend({}, {
        delay: 1000,
        duration: 1000,
        easing: 'linear',
        endless: false
    }, options);
    var elem = $(this);
    (function loop(i) {
        var e = typeof text === 'string' ? text : text[i];
        // strip html tags, might be helpful
        // e.replace(/(<.*?>)/ig,"")
        $({len: 0}).delay(options.delay).animate({len: e.length}, {
            duration: options.duration,
            easing: options.easing,
            step: function (now) {
                var pos = Math.ceil(now),
                    char = e.substr(pos, 0);
                elem.html(e.substr(0, pos));
            },
            complete: function () {
                i++;
                if (i === text.length && !options.endless) {
                    return;
                } else if (i === text.length) {
                    i = 0;
                }
                loop(i);
            }
        });
    })(0);
};

$('#foo').typer(['<i>Anyone</i> <u>is</u> <b>awesome</>!', 'Foo bar.']);

Working demo:

http://jsfiddle.net/ARTsinn/RED9H/2/

Update

Got it!

example without jQuery‘s animate-function.

If you’ve any improvements, share them here!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:46:03+00:00Added an answer on June 18, 2026 at 9:46 am

    To strip the tags from e, use:

    e = $(e).text();
    

    This assumes e is known to contain HTML to begin with. If it might contain plain text, wrap it in a DIV first:

    e = $('<div>'+e+'</div>').text();
    

    Otherwise, jQuery will try to interpret it as a selector.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to provide a simple RESTful API to my ASP MVC project.
I'm trying to use ThreadLocal to provide thread safety to pre-existing non-thread-safe classes, but
I've been trying to get my own opinion about this issue but could not,
Hi I'm trying to get the referrer url but it doesn't work when the
Can anyone tell me or provide a full (but simple) example on how to
I have a simple authentication provider that I'm trying to use with Spring Security.
I have a simple table structure Images(image_id, image_library_id,...) Links(link_id, image_id, link_component_code...) I am trying
I have been trying to generate simple PDFs from my app so that I
I have been using generics for sometime, but only in a simple straightforward fashion.
I'm trying to provide a link to the attachment of a note through the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.