<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{padding:0;margin:0;}
#toggle{width:200px;height:200px;border:1px solid #0046a3;overflow:hidden;}
#toggle_num{width:150px;position:relative;top:180px;left:25px;background:#f3f3f3;}
#toggle_num ul{padding:0;margin:0;list-style:none;}
#toggle_num ul li{width:20px;height:20px;line-height:20px;border:1px solid #0046a3;color:#ffffff;float:left;text-align:center;margin:0 15px 0 0;}
.styleA{font:20px "宋体";background:#ff0000;}
.styleB{font:20px "宋体";background:#ffffff;}
</style>
<script type="text/javascript">
var curNew = 0;
function $(elem){
return typeof elem == 'string' ? document.getElementById(elem) : elem;
}
function addEvent(obj,type,func){
if(obj.addEventListener){
obj.addEventListener(type,func,false);
}
if(obj.attachEvent){
obj.attachEvent("on" + type,func);
}
}
function com(obj,listElem){
_com = this;
_com.obj = $(obj);
_com._list = _com.obj.getElementsByTagName(listElem);
}
com.prototype._addEvent = function(){
for(var i = _com._list.length - 1;i >= 0;i--){
var j = i;
_com._list[i].onclick = new Function('curNew='+(i-1)+';com.prototype.afterEvent();');
/* _com._list[i].onclick = function(){
curNew = j - 1;
com.prototype.afterEvent();
};*/
}
//curNew--;
com.prototype.afterEvent();
};
com.prototype.afterEvent = function(){
curNew = curNew + 1;
if(curNew > _com._list.length)
curNew = 0;
for(var i = 0;i < _com._list.length;i++){
if(i == (curNew-1))_com._list[i].className = "styleA";
else _com._list[i].className = "styleB";
}
if(timer)clearTimeout(timer);
var timer = setTimeout("com.prototype.afterEvent()",3000);
};
</script>
</head>
<body>
<div id="toggle">
<div id="toggle_num">
<ul><li>1</li><li>2</li><li>3</li><li>4</li></ul>
</div>
</div>
<script type="text/javascript">
(function(){
var b = new com("toggle_num","li");
b._addEvent();
})();
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{padding:0;margin:0;}
#toggle{width:200px;height:200px;border:1px solid #0046a3;overflow:hidden;}
#toggle_num{width:150px;position:relative;top:180px;left:25px;background:#f3f3f3;}
#toggle_num ul{padding:0;margin:0;list-style:none;}
#toggle_num ul li{width:20px;height:20px;line-height:20px;border:1px solid #0046a3;color:#ffffff;float:left;text-align:center;margin:0 15px 0 0;}
.styleA{font:20px "宋体";background:#ff0000;}
.styleB{font:20px "宋体";background:#ffffff;}
</style>
<script type="text/javascript">
var curNew = 0;
function $(elem){
return typeof elem == 'string' ? document.getElementById(elem) : elem;
}
function addEvent(obj,type,func){
if(obj.addEventListener){
obj.addEventListener(type,func,false);
}
if(obj.attachEvent){
obj.attachEvent("on" + type,func);
}
}
function com(obj,listElem){
_com = this;
_com.obj = $(obj);
_com._list = _com.obj.getElementsByTagName(listElem);
}
com.prototype._addEvent = function(){
for(var i = _com._list.length - 1;i >= 0;i--){
var j = i;
_com._list[i].onclick = new Function('curNew='+(i-1)+';com.prototype.afterEvent();');
/* _com._list[i].onclick = function(){
curNew = j - 1;
com.prototype.afterEvent();
};*/
}
//curNew--;
com.prototype.afterEvent();
};
com.prototype.afterEvent = function(){
curNew = curNew + 1;
if(curNew > _com._list.length)
curNew = 0;
for(var i = 0;i < _com._list.length;i++){
if(i == (curNew-1))_com._list[i].className = "styleA";
else _com._list[i].className = "styleB";
}
if(timer)clearTimeout(timer);
var timer = setTimeout("com.prototype.afterEvent()",3000);
};
</script>
</head>
<body>
<div id="toggle">
<div id="toggle_num">
<ul><li>1</li><li>2</li><li>3</li><li>4</li></ul>
</div>
</div>
<script type="text/javascript">
(function(){
var b = new com("toggle_num","li");
b._addEvent();
})();
</script>
</body>
</html>
解决方案 »
- 求ueditor或其他html编辑器的开发文档
- 如何在多选的下拉框没有值被选中的情况下,提交所有值
- 请教如何通过JS获取iframe 里面div的id值?
- 想问一下JS三级树形菜单的设计思想
- ExtJS 数据加载
- javascript正则表达式验证邮箱不判断是否有.的问题
- SELECT对象的怪事,当一个SELECT的OPTION被复制时,其select会自动发生变化?
- 求一代码(颜色选择)
- 关于不同浏览器下面的页面显示效果?
- 页面由两个iframe分成两半,怎么在两个iframe间加上线,其可拖动来动态调整两iframe宽度?
- 自动填写的文本框??
- 现在有这么个滑动门搜索……请问我该如何识别呢?
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
*{padding:0;margin:0;}
#toggle{width:200px;height:200px;border:1px solid #0046a3;overflow:hidden;}
#toggle_num{width:150px;position:relative;top:180px;left:25px;background:#f3f3f3;}
#toggle_num ul{padding:0;margin:0;list-style:none;}
#toggle_num ul li{width:20px;height:20px;line-height:20px;border:1px solid #0046a3;color:#ffffff;float:left;text-align:center;margin:0 15px 0 0;}
.styleA{font:20px "宋体";background:#ff0000;}
.styleB{font:20px "宋体";background:#ffffff;}
</style>
<script type="text/javascript">
var curNew = 0;
var timer;
function $(elem){
return typeof elem == 'string' ? document.getElementById(elem) : elem;
}
function addEvent(obj,type,func){
if(obj.addEventListener){
obj.addEventListener(type,func,false);
}
if(obj.attachEvent){
obj.attachEvent("on" + type,func);
}
}
function com(obj,listElem){
_com = this;
_com.obj = $(obj);
_com._list = _com.obj.getElementsByTagName(listElem);
}
com.prototype._addEvent = function(){
for(var i = _com._list.length - 1;i >= 0;i--){
var j = i;
_com._list[i].onclick = new Function('curNew='+(i)+';com.prototype.afterEvent();');
/* _com._list[i].onclick = function(){
curNew = j - 1;
com.prototype.afterEvent();
};*/
}
//curNew--;
com.prototype.afterEvent();
};
com.prototype.afterEvent = function(){
for(var i = 0;i < _com._list.length;i++){
if(i == (curNew))_com._list[i].className = "styleA";
else _com._list[i].className = "styleB";
}
curNew++;
if(curNew > _com._list.length-1) curNew = 0;
if(timer)clearTimeout(timer);
timer = setTimeout("com.prototype.afterEvent()",3000);
};
</script>
</head>
<body>
<div id="toggle">
<div id="toggle_num">
<ul><li>1</li><li>2</li><li>3</li><li>4</li></ul>
</div>
</div>
<script type="text/javascript">
(function(){
var b = new com("toggle_num","li");
b._addEvent();
})();
</script>
</body>
</html>