昨天我在找一個使用javascript的文字效果。我被指向這個小提琴:http://jsfiddle.net/vCx6W/1/,這是它發佈的地方:https://stackoverflow.com/questions/4074399/what-to-choose-for-typewriter-effect-in-javascript如何使此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>
但是,我無法使文本顯示在所有。我究竟做錯了什麼?
對我來說正常工作與糾正jquery路徑 – HashtagMarkus