(求助)图片点击轮换效果
前几天做了一个效果,感觉有点麻烦,不是有点,是相当麻烦了,谁帮我改进一下.或者换个思路.下面是我的源文件. [html]
<!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=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.s0{ display:block;}
.s1{ display:none;}
</style>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="#" onclick="chaPic(-1);">左</a></td>
<td id="imgAll">
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0614.jpg" class="s0"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0631.jpg" class="s1"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0630.jpg" class="s1"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0633.jpg" class="s1"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0635.jpg" class="s1"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0639.jpg" class="s1"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0619.jpg" class="s1"/>
<img src="http://desk.blueidea.com/desk/XP/225/xpbz0615.jpg" class="s1"/>
</td>
<td><a href="#" onclick="chaPic(1);">右</a></td>
</tr>
</table>
<script type="text/javascript">
var picNum=0
function chaPic(g){
var s=document.getElementById("imgAll").getElementsByTagName("img"),j=s.length;
picNum+=g
if(picNum>=j){alert("到最后了");picNum-=g;return}
if(picNum<0){alert("前面没有了");picNum-=g;return}
for (var i=0;i<j;i++){s[i].className="s1"}
s[picNum].className="s0"
}
</script>
</body>
</html>
[/html]
[[i] 本帖最后由 caiying2007 于 2008-8-29 11:37 编辑 [/i]] 确实挺精简的,能不能在问一下:
if(picNum>=j){alert("到最后了");picNum-=g;return}
最后那个return 什么意思 return:从当前函数退出,并从那个函数返回一个值。
这个不需要返回一个值吧! 是不是就退出的意思 感谢楼主和2楼的帮助,这个效果非常简单有用
回复 4# gevilhost [楼主] 的帖子
就是这个意思try:
[html]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 2</title>
</head>
<body>
<input id="ttt" value="请输入大于10的数字" onfocus="this.value=''"><input type="button" value="ok" onclick="returnV()">
<script>
function returnV(){
var V=document.getElementById("ttt").value
alert("getV(V)="+getV(V))
if (getV(V)) alert("谢谢")
}
function getV(_V){
if (_V>10)return 1;//退出,返回"1"
else return;//退出,不返回值
}
</script>
</body>
</html>
[/html] 很精彩哦~~~爱死你喽caiying2007
页:
[1]