关于jQuery问题:怎么使用setTimeout方法总是在最后弹出空。。郁闷
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>幻灯片</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jquery.ba-dotimeout.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var index = 1;
$("#test1").click(function(){
});
$(".transfer").mouseover(function(){
});
$(".transfer").mouseout(function(){
});
function showImage(){
if(index == 5){
index = 1;
}
var image = "images/photo"+index+".jpg";
index = parseInt(index)+1;
$("#transImage").attr("src",image);
}
setInterval("showImage()",1000);
});
$.doTimeout("typing",2000,function(){
alert("");
});
</script>
</head>
<body>
<div id="network">
<div class="wrap">
<div class="network">
<div class="transfer">
<img id="transImage" src="images/photo1.jpg" />
<ul>
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</div>
</div>
<input type="button" id="test1" value="click me"/>
<input id="test2" value="fdskfjkd"/>
<input type="button" id="test3" value="click m3e"/>
</body>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>幻灯片</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="jquery.ba-dotimeout.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var index = 1;
$("#test1").click(function(){
});
$(".transfer").mouseover(function(){
});
$(".transfer").mouseout(function(){
});
function showImage(){
if(index == 5){
index = 1;
}
var image = "images/photo"+index+".jpg";
index = parseInt(index)+1;
$("#transImage").attr("src",image);
}
setInterval("showImage()",1000);
});
$.doTimeout("typing",2000,function(){
alert("");
});
</script>
</head>
<body>
<div id="network">
<div class="wrap">
<div class="network">
<div class="transfer">
<img id="transImage" src="images/photo1.jpg" />
<ul>
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</div>
</div>
<input type="button" id="test1" value="click me"/>
<input id="test2" value="fdskfjkd"/>
<input type="button" id="test3" value="click m3e"/>
</body>
</html> 展开
展开全部
改成这样就行,dotimeout.js可以不用。
$(document).ready(function(){
var index = 1;
function showImage(){
if(index == 5){
index = 1;
}
index = parseInt(index)+1;
var image = "images/photo"+index+".jpg";
$("#transImage").attr("src",image);
setTimeout(showImage,1000);
}
showImage();
});
$(document).ready(function(){
var index = 1;
function showImage(){
if(index == 5){
index = 1;
}
index = parseInt(index)+1;
var image = "images/photo"+index+".jpg";
$("#transImage").attr("src",image);
setTimeout(showImage,1000);
}
showImage();
});
2011-11-21
展开全部
不知道
$.doTimeout("typing",2000,function(){
alert("");
});
要做什么,
但是
setInterval("showImage()",1000);
明显写错了
应该是setInterval(showImage,1000);
$.doTimeout("typing",2000,function(){
alert("");
});
要做什么,
但是
setInterval("showImage()",1000);
明显写错了
应该是setInterval(showImage,1000);
更多追问追答
追问
那如果我要用得setTimeout的话,也是这么写得么
追答
不管你用不用,你得保证代码写得是对的,不是说你不用setTimeout,就能写成setInterval("showImage()",1000);
用不用都得写成setInterval(showImage,1000);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询