昨天我正在寻找使用 javascript 的文本效果。我被指着这个小提琴: http: //jsfiddle.net/vCx6W/1/这是它发布的地方: https ://stackoverflow.com/questions/4074399/what-to-choose-for-typewriter-effect -in-javascript
我正在尝试使用相同的东西。我添加了这样的javascript:
<script type="text/javascript" src="http://code.jquery.com/
jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$.fn.teletype = function(opts) {
var $this = this,
defaults = {
animDelay: 50
},
settings = $.extend(defaults, opts);
$.each(settings.text, function(i, letter) {
setTimeout(function() {
$this.html($this.html() + letter);
}, settings.animDelay * i);
});
};
$(function() {
$('#container').teletype({
animDelay: 100,
text: 'Now is the time for all good men to come to the aid of their country...'
});
});
</script>
这在 HTML 中:
<div id="container"></div>
但是,我根本无法使文本出现。我究竟做错了什么?