This example describes the flash input effect of JavaScript and jquery implementations. Share to everyone for your reference, specific as follows:
HTML section
<div id= "code" >
<p>/**</p>
<p>*2014-2-12</p>
<p>* codes automatic flashing input </p >
<p>*/</p>
2014-2-14,i want to say:<br/>
Baby, I love you forever!<br/>
& Lt;/div>
JS part
function typewriter (id) {
var $ele = document.getElementById (ID);
var str = $ele. InnerHTML, progress = 0;
$ele. InnerHTML = ';
var timer = setinterval (function () {
var current = Str.substr (progress, 1);
if (current = = <) {
progress = str.indexof (' > ', progress) + 1;
} else {
progress++;
}
$ele. InnerHTML =str.substring (0, progress) + (Progress & 1?) '_' : '');
if (Progress >= str.length) {
clearinterval (timer);}}
, m);
How to use:
into a jquery plugin.
(function ($) {
$.fn.typewriter = function () {
var $ele = $ (this), str = $ele. HTML (), progress = 0;
$ele. HTML (');
var timer = setinterval (function () {
var current = Str.substr (progress, 1);
if (current = = <) {
progress = str.indexof (' > ', progress) + 1;
} else {
progress++;
}
$ele. HTML (str.substring (0, progress) + (Progress & 1?) '_' : ''));
if (Progress >= str.length) {
clearinterval (timer);}}, N;}
;}
) (JQuery);
How to use:
$ ("#code"). Typewriter ();
More readers interested in JavaScript-related content can view this site: "JavaScript in the JSON Operation tips Summary", "JavaScript animation effects and tips Summary", "JavaScript extension skills summary", " A summary of JavaScript motion effects and techniques, a summary of JavaScript mathematical operational usage, and a JavaScript-oriented introductory tutorial
I hope this article will help you with your JavaScript programming.