<分区>
标签 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>
提前致谢:)
最佳答案
从您的 src 标签中删除空格!
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
关于javascript - jQuery 在一段时间后更改文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27462960/