我正在尝试设置旋转文字横幅。标语是使用嵌入式样式创建的。但是,我的脚本似乎覆盖了我的内联样式。
这是我所拥有的:
$(window).load(function(){
var cnt=0, texts=[];
// save the texts in an array for re-use
$(".textContent").each(function() {
texts[cnt++]=$(this).text();
});
function slide() {
if (cnt>=texts.length) cnt=0;
$('#textMessage').html(texts[cnt++]);
$('#textMessage')
.fadeIn('slow').animate({opacity: 1.0}, 5000).fadeOut('slow',
function() {
return slide()
}
);
}
slide()
div.textContent { display:none;}
<div id="textMessage"></div>
<div class="textContent"><h2 style="padding:6px !important; background-color:#003768 !important; color:#8DC63F !important; font-size:27px !important;"><em>
Outsourcing ATMs - the smarter solution.</em>
</h2></div>
<div class="textContent"><h2 style="padding:6px; background-color:#003768; color:#8DC63F; font-size:27px;"><em>
Who spends ALL DAY on ATM Management? <span style="color:white";>Outsource ATM</span></em>
</h2></div>
<div class="textContent"><h2 style="padding:6px; background-color:#003768; color:#8DC63F; font-size:27px;"><em>
Quality service companies anticipate the needs of their clients by providing solutions - not more work.</em>
</h2>
</div>
最佳答案
将text()
更改为html()
https://jsfiddle.net/4aj7kg2q/
$(".textContent").each(function() {
texts[cnt++]=$(this).html();// html if you want to keep styles
});
关于javascript - 标语中间隔时间的Javascript文本更改-无需点击,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39737727/