Search code examples
javascripthyperlinkeffecttyped

Link in typed.js text


How do i put link in typed.js script? I need Contact me, to be linked to contact page.

    <script src="js/typed.js"></script>
    <script>
      $(function(){
          $(".element").typed({
            strings: ["Welcome to my Website.", "Random text... Contact me"],
            typeSpeed: 0
          });
      });
    </script>

 **HTML**

<div class="col-md-12 col-xs-12">
    <h1 class="element"></h1>
 </div>

Solution

  • Use the callback parameter.

    Example:

    $(function() {
      $('#awesome').typed({
        strings: ["Welcome to my Website.", "Random text... Contact me"],
        typeSpeed: 0,
        callback: function() {
          $('#awesome').html('<a href="#">' + $('#awesome').html() + '</a>')
        }
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://raw.githubusercontent.com/mattboldt/typed.js/master/js/typed.js"></script>
    
    <div class="col-md-12 col-xs-12">
      <h1 class="element" id="awesome"></h1>
    </div>