如何使用 Javascript 或 html 为我的网站制作跨浏览器友好的文本轮播?我一直在努力处理下面的代码,因为它只适用于 Firefox,但在 IE 上失败。有没有办法让它同时适用于两者?
<h4>Carousel-Text-Below </h4>
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'
type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function(){
function setRandomWord(){
var phrases =new Array("1-Blah Text","2-Blah Text","3-Blah Text");
$("#test").text(phrases[Math.floor(Math.random()*phrases.length)]);
}
setInterval(setRandomWord,3000);
});
</script>
</head>
<body>
<p style="border:1px dashed gray; background-color:white; padding: 10px">
<span id='test'>Blah Text-Text-Text</p>
</span> Guaranteed Service or...Text---Text</strong></p>
</body>
</html>
最佳答案
我认为这是因为您没有设置文档类型。在这里尝试过,它适用于 <!DOCTYPE html>
在<html>
前面标签。
关于javascript - 如何使用 javascript 或 html 为我的网站制作跨浏览器友好的文本轮播?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14308748/