jQuery的打字機效果很炫哦,想實現這種效果的請看詳細步驟:
1、引用jquery庫,下載地址就不用多講了吧。
2、如何調用呢,$("#msg").typewriter(100); 這裏的100爲速度,可以根據自己的需求進行配置。
3、附:打字機方法:
(function(a) {
a.fn.typewriter = function(speed) {
this.each(function() {
var d = a(this),
c = d.html(),
b = 0;
d.html("");
var e = setInterval(function() {
var f = c.substr(b, 1);
if (f == "<") {
b = c.indexOf(">", b) + 1
} else {
b++
}
d.html(c.substring(0, b) + (b & 1 ? "_": ""));
if (b >= c.length) {
clearInterval(e)
}
},
speed)
});
return this;
}
})(jQuery);