首页 > 其他 > 详细

打字机效果

时间:2015-12-07 18:06:07      阅读:259      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>打字机效果</title>
<style type="text/css">
body{margin:0;padding:0;background:#ffe;font-size:12px;overflow:auto}
#mainDiv{width:500px;height:100%;margin: 0 auto;margin-top: 100px;}
#code{float:left;width:440px;height:400px;color:#333;font-size:12px;margin:200px 0 0 200px;}
</style>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script type="text/javascript">
(function($) {
$.fn.typewriter = function() {
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);
//}
}, 100);
});
return this;
};
})(jQuery);
$(function(){
$("#code").typewriter();
})
</script>
</head>
<body>
<div id="box">
<div id="content">
<div id="code">
如果你认识以前的我,那么你会原谅现在的我。
</div>
</div>
</div>
</body>
</html>

打字机效果

原文:http://www.cnblogs.com/lixiaoxing/p/5026410.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!