jQuery一次又一次改变文本?

时间:2014-12-13 19:50:55

标签: javascript jquery html css ajax

我在stackoverflow HERE上找到了这个代码,但它对我不起作用......

我只能看到这个:

Hello world!
Here is a message: 

,但我没有看到时间之后应该改变的消息......

我从我的文件index.html中复制/粘贴整个代码:

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">


</script>
</head>
<body>
<script type="text/javascript">
function nextMsg() {
    if (messages.length == 0) {
        alert("redirecting");
    } else {
        $('#message').html(messages.pop()).fadeIn(500).delay(1000).fadeOut(500,     nextMsg);
    }
};

var messages = [
    "Hello!",
    "This is a website!",
        "You are now going to be redirected.",
    "Are you ready?",
    "You're now being redirected..."
].reverse();

$('#message').hide();
nextMsg();
</script>

<h1>Hello world!</h1>
<p>Here is a message: <span id="message"></span></p>
</body>
</html>

提前致谢:)

1 个答案:

答案 0 :(得分:1)

从src标签中删除空格!     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">