标签:io ar sp on cti html amp bs htm
(function($) { $.fn.typewriter = function(cb) { this.each(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); if(typeof cb == ‘function‘){ cb(); } if(str[str.length-1] == ‘_‘){ str=substr(0,str.length-1); } $ele.html(str); } }, 75); }); return this; }; })(jQuery);
标签:io ar sp on cti html amp bs htm
原文地址:http://my.oschina.net/wizardpisces/blog/333970