Is it possible to control when the typed.js plugin starts and stops typing text?

The jquery plugin typed.js is used to make text appear to be automatically typed on screen by a robot. I have explored the resources surrounding the plugin, but I have not found any info on how to start and stop text from typing.

My goal is to have four different series of texts that would be typed on screen and each one would be triggered by clicking a button. They would all be located within the same space in the same div, so if "Button A" is clicked, "Text A" begins typing. If "Button B" is clicked midway through the typing, then the text would be deleted and "Text B" would begin typing.

To achieve this effect, I need to be able to control when typed.js starts and stops typing text. Is this possible?

Answers 1

  • Here is an example showing how to activate typed.js when you click a button, it can be adapted to whatever you need it to do.

    Javascript:

    $(function() {
        var options = {
          strings: ["First sentence.", "Second sentence."],
          typeSpeed: 0
        }
        $("button").click(function() {
          $(".element").typed(options);
        });
    });
    

    HTML:

    <span class="element"></span><br />
    <button>Type!</button>
    

    The JSFiddle: http://jsfiddle.net/mattboldt/tcRUG/

    Source: The Wiki of the GitHub Project of typed.js


Related Articles