我試圖使用fadeToggle()
使數組中的文本淡入,等待10秒,而不是淡出另一個文本做同樣的事情。修復褪色文本在jQuery中使用fadeToggle()
這段代碼的文本每隔幾秒鐘切換完美,我只是不能得到正確的代碼,使其淡入/淡出:
var texts = [" \" It's really hard to design products by focus groups. A lot of times, people don't know what they want until you show it to them. \" <br /> ~ Steve Jobs ", " \" Design is not just what it looks like and feels like. Design is how it works \" <br /> ~ Steve Jobs", " \" That’s been one of my mantras — focus and simplicity. Simple can be harder than complex ; you have to work hard to get your thinking clean to make it simple. \" <br /> ~ Steve Jobs", " \" The present is theirs ; the future, for which I really worked, is mine. \" <br /> ~ Nikola Tesla ", " \」 The value of an idea lies in the using of it. \「 <br /> ~ Thomas Edison "];
var count = 0;
$(document).ready(function() {
function changeText() {
$(".quote").html(texts[count]);
count < texts.length ? count++ : count = 0;
}
setInterval(changeText, 1000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1 class="quote">Hello</h1>
謝謝!效果很好。 –