我想用jquery“淡化效果”每隔3秒更改一次p的文本:
<p class="first">Conected</p>
到
<p class="second">2547</p>
答案 0 :(得分:3)
您可以使用setInterval https://developer.mozilla.org/en-US/docs/DOM/window.setInterval
setInterval(function() {
$('p').fadeOut(500, function() {
var $this = $(this);
$this.text($this.text() == 'Connected' ? '2457' : 'Connected');
$this.toggleClass('first second');
$this.fadeIn(500);
});
}, 3000);
答案 1 :(得分:-1)
setInterval或等待
的setInterval http://www.w3schools.com/js/js_timing.asp
JQuery等待 http://api.jquery.com/delay/