0

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>
4

2 に答える 2

1

Doctype セットを持っていないためだと思います。ここで試してみると、タグ<!DOCTYPE html>の前で動作します。<html>

于 2013-01-13T22:11:36.577 に答える
1

無効な HTML によって IE が混乱している可能性がありますか? 内部を<p>閉じる前に を閉じていることに注意してください。<span>それからあなたもまた比類のないものを持ってい</strong>ます</p>。私はあなたがこれを意味したと信じています:

<p style="border:1px dashed gray; background-color:white; padding: 10px">
    <span id='test'>Blah Text-Text-Text</span>
    <strong>Guaranteed Service or...Text---Text</strong>
</p>

http://jsfiddle.net/xrS3t/

または多分

<p style="border:1px dashed gray; background-color:white; padding: 10px">
    <span id='test'>Blah Text-Text-Text</span>
</p>
<p>
    <strong>Guaranteed Service or...Text---Text</strong>
</p>

http://jsfiddle.net/6nFVK/

現在、テストする IE を持っていません。上記の jsfiddle リンクを試していただけますか?

于 2013-01-13T22:20:58.573 に答える