ITeye博客

实现打字机打字的效果

小杨学JAVA · 2014-01-15 10:10 · jQuery · js · Web前端 · Markdown

(function(a) {
	a.fn.typewriter = function() {
		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)
				}
			},
			75)
		});
		return this
	}
})(jQuery);

 转,不是原创用来学习

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。