javascript - typed.js doesn't work for the second attempt -


the first attempt hover div.logo finish , typed.js types sentence. after that, when hover again on div.logo doesn't work , doesn't type anything.

    <script type="text/javascript">     $( ".logo" ).hover(function() {         $(this).toggleclass("clicked");         if ($('.logo').hasclass('clicked')){               $(function(){                 $('.logo').css('background-position','-20vmin center');                 console.log("n");                   $(".logo h3").typed({                     strings: ["phoenix ^250 programming ^250 team"],                     typespeed: 75                   });               });         }         else{             $('.logo').find( "h3" ).text("");             $('.logo span').remove();             $('.logo').css('background-position','center left+1.5vmin');         }     });     </script> 

as can see in source code typed.js, function typed() assigns data target element, , refuses run if such data set:

var $this = $(this),     data = $this.data('typed'), // <<<     options = typeof option == 'object' && option; if (!data) // <<<     $this.data('typed', (data = new typed(this, options))); 

therefore have unset before calling typed() twice:

$('.logo h3')     .data('typed', null) // <<<     .typed({         strings: ["phoenix ^250 programming ^250 team"],         typespeed: 75     }); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -