How can i Execute type() function when erase() function completes

Here is a typing animation JS, and here are two function work correctly type() function when we click type button and the erase() function when we click on Erase button.

But now i want to create here a new function that is Erase and Retype means simply i want – When the sentences typed completely and then if we click Erase and Retype button then it should be erase and retype once.

var captionLength = 0;
var caption = '';

$(document).ready(function () {
  captionEl = $('#caption');

  $('#test-typing').click(function () {

  $('#test-erasing').click(function () {

function testTypingEffect() {
  caption =  $("#qqq").html();

function type() {
  captionEl.html(caption.substr(0, captionLength++));
  if (captionLength < caption.length + 1) {
    setTimeout('type()', 5);
  } else {
    captionLength = 0;
    caption = '';

function testErasingEffect() {
  caption = captionEl.html();
  captionLength = caption.length;
  if (captionLength > 0) {
  } else {
    $('#caption').html("You didn't write anything to erase, but that's ok!");
    setTimeout('testErasingEffect()', 1000);

function erase() {
  captionEl.html(caption.substr(0, captionLength--));
  if (captionLength >= 0) {
    setTimeout('erase()', 5);
  } else {
    captionLength = 0;
    caption = '';
<div id="qqq">this is some example sentence which I want to </div>

    <input type="button" id="test-typing" value=" Type" />
    <input type="button" id="test-erasing" value="Erase" />  
    <input type="button" id="test-erase-and-retype" value="Erase & Retype" /> 

<span id="caption"></span>

  <script src=''></script>

i tried to this help, but i didn’t get success can i know plz what i should to do.

i have already tried this code:

using callback:

  $('#test-erase-and-retype').click(function () {
testErasingEffect(function () {

using when and then condition:

  $('#test-erase-and-retype').click(function () {

and this

  $('#test-erase-and-retype').click(function () {

    function firstFunction(){
    function secondFunction(){

But all that not working, this only erase text not Re-Type.

Can i know what mistake am making ?

72 thoughts on “How can i Execute type() function when erase() function completes”

  1. I’ve been exploring for a bit for any high-quality articles or weblog posts on this kind of space .
    Exploring in Yahoo I ultimately stumbled upon this site.
    Studying this info So i am happy to convey that I have an incredibly excellent
    uncanny feeling I found out exactly what
    I needed. I most indubitably will make certain to don?t forget this
    website and provides it a look on a relentless basis.

    Also visit my homepage :: Ultra Cut Keto Ingredients

  2. I simply could not leave your web site prior to suggesting that I really
    enjoyed the usual information a person supply for your guests?
    Is going to be back continuously in order to investigate cross-check new posts.

    My web-site …

  3. Someone essentially help to make critically posts I might state.
    This is the first time I frequented your website page and
    up to now? I amazed with the research you made to create this particular submit
    incredible. Excellent job!

    Also visit my homepage ::

  4. Greetings from Idaho! I’m bored to death at work so I decided to check out your blog on my iphone during lunch break.
    I love the info you present here and can’t wait
    to take a look when I get home. I’m shocked at how quick your blog loaded on my mobile
    .. I’m not even using WIFI, just 3G .. Anyhow, wonderful site!

    my web site …

  5. Pretty part of content. I just stumbled upon your website and in accession capital to say that I acquire in fact enjoyed account your weblog posts.

    Anyway I will be subscribing on your augment and even I achievement you get admission to persistently fast.

    My webpage ::

  6. I rarely drop comments, however i did a few searching and wound up here
    How can i Execute type() function when erase() function completes
    – JavaScript Help. And I do have some questions for you if
    it’s allright. Is it simply me or does it look as if like
    some of these comments look as if they are written by brain dead people?
    😛 And, if you are posting at other online social sites, I would like to
    keep up with anything fresh you have to post. Would you list of all of all your
    public sites like your twitter feed, Facebook page or linkedin profile?

    my web site ::

  7. First off I would like to say terrific blog!
    I had a quick question which I’d like to ask if you don’t mind.
    I was curious to find out how you center yourself and clear your thoughts
    prior to writing. I have had a hard time clearing my thoughts
    in getting my ideas out there. I do enjoy writing but it just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any ideas or hints?

    my website :: Keto Redux Reviews

  8. Thank you so much for giving everyone an exceptionally superb possiblity to read from this blog.
    It is always so pleasing and also full of amusement for me and my office acquaintances to visit the blog the equivalent of 3 times
    per week to see the newest stuff you have got. And of course, I
    am at all times fulfilled with your unique solutions served by you.
    Some 3 facts on this page are undoubtedly the finest we have had.

    my web blog; Green Earth CBD Gummies Review

  9. I know this if off topic but I’m looking into starting my own weblog
    and was wondering what all is required to get setup? I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web savvy so I’m not 100% certain. Any tips or advice would be greatly appreciated.
    Many thanks

    My blog post; SoloVolt Reviews

  10. I seriously love your site.. Great colors & theme.
    Did you make this website yourself? Please reply back as I?m planning to create
    my own site and want to find out where you got
    this from or what the theme is called. Thanks!

    Also visit my web blog; ACV Rx Review

  11. I believe that is one of the such a lot
    important info for me. And i am glad studying your article.
    However want to statement on few normal things, The site
    taste is great, the articles is actually great : D. Just right activity,

  12. Simply to follow up on the up-date of this theme on your site and want to
    let you know just how much I prized the time you
    took to create this helpful post. Within the post, you actually spoke regarding how to really handle this matter with all comfort.
    It would be my pleasure to accumulate some more strategies
    from your web page and come up to offer people what I learned from
    you. Many thanks for your usual excellent effort.

    my web page –

  13. Hello there! This is my first visit to your blog! We are a team of volunteers and starting a new
    project in a community in the same niche. Your
    blog provided us valuable information to work on. You have
    done a outstanding job!

    Look into my web blog; Keto BHB Plus

  14. Thank you, I have just been looking for information approximately
    this subject for a long time and yours is the best I have came upon so far.

    However, what about the bottom line? Are you certain about the supply?

    Visit my web blog :: Arielle

  15. We would like to thank you yet again for the
    stunning ideas you offered Jesse when preparing
    a post-graduate research plus, most importantly,
    regarding providing all of the ideas in one blog post. Provided that
    we had been aware of your web-site a year
    ago, we would have been saved the useless measures we were implementing.
    Thank you very much.

    my blog – Erorectin Pills

  16. Right here is the perfect web site for anyone
    who wants to understand this topic. You know so much its almost tough to argue with you (not that I actually will need to?HaHa).
    You certainly put a new spin on a subject that has been written about for a long time.
    Excellent stuff, just excellent!

    my page :: Erorectin Ingredients


Leave a Comment