//text in turn comes out effect$.fn.autotype =function() { var$text = $ ( This); //Console.log (' This ', this); varstr = $text. HTML ();//returns the contents of the selected element varindex = 0; varx = $text. HTML ('); //$text. HTML () and (this). HTML (") is different varTimer = SetInterval (function() { //substr (Index, 1) method extracts a character in a string that starts with index subscript varCurrent = STR.SUBSTR (index, 1); if(current = = ' < ') { //The indexOf () method returns the position of the first occurrence of ">" in the String. index = Str.indexof (' > ', index) + 1; } Else{Index++; } //Console.log (["0 to index subscript character", str.substring (0, index)],["symbol", Index & 1? ' _ ': ']); //the substring () method is used to extract the character of a string intermediary between two specified subscripts$text. HTML (str.substring (0, index) + (index & 1?) ‘‘: ‘‘)); if(Index >=str.length) {clearinterval (timer); } }, 100);} $('. Font '). AutoPlay ();
//the text turns out to be effective, this method is feasible, but the process step more easily chaotic varCon = $ (". FontX"); varindex = 0; varTid =NULL; functionStart (s) {varLen =s.length; Con.text (‘‘); Tid= SetInterval (function() {con.append (S.charat (index)); if(Index + = = = =Len) {clearinterval (TID); Index= 0; } },100); }start (str)
JS Typing effect