I. Methods of Use
<link rel= "stylesheet" type= "Text/css" href= "Typeit.css" >
<script src= "Jquery-2.1.4.min.js" ></script>
<script src= "Typeit.js" ></script>
Second, HTML structure
<span class= "Type-it" ></span>
Third, initialize the plug-in
<span class= "Type-it"
Data-typeit-whattotype= "A new string to type."
data-typeit-speed= "100"
Data-typeit-lifelike= "true"
Data-typeit-showcursor= "true" >
</span>
$ ('. Type-it '). Typeit ();
The second way is to pass in the configuration parameters when initializing the plug-in.
$ ('. Type-it '). Typeit ({
Whattotype: ' Enter your string here! ',
TYPESPEED:300,
Lifelike:false,
Showcursor:true
});
The typewriter plugin supports entering text for multiple sentences. By default, each sentence occupies one line, which appears from the top down. To use multiple lines of sentences, you only need to pass in an array.
$ ('. Type-it '). Typeit ({
whattotype:[' Enter your string here! ', ' another string! ']
});
You can also set the new center to overwrite the old sentence's typing effect, just set the Breaklines parameter to False.
$ ('. Type-it '). Typeit ({
Whattotype: [' Enter your string here! ', ' another string! '],
Breaklines:false
});
Four, callback function
After the text is printed, you can set a callback function to do other work.
$ ('. Typeit-box '). Typeit ({
Whattotype: ' Here is a string! ',
}, function () {
Console.log (' This is your callback function! ');
});
Keymob is currently the leading mobile advertising platform, dedicated to mobile app developers to create the best mobile advertising revenue, for tens of thousands of app advertisers to provide accurate wireless marketing and brand promotion services.
HTML5 Add lightweight responsive Typewriter Plugin tutorial