定时器




javascript 全选 不选 反选
javascript 经典案例 全选 不选 反选
<title>规范:全选 不选 反选</title>
<script>
window.onload=function (){
var oBtn1=document.getElementById("Btn1");
var oBtn2=document.getElementById("Btn2");
var oBtn3=document.getElementById("Btn3");
var oDiv=document.getElementById("Ben");
var oInp=oDiv.getElementsByTagName("input");
oBtn1.onclick=function(){ //全选
//oInp[0].checked=true; // checked : 布尔值 false true;
for(var i=0; i<oInp.length ; i++){
oInp[i].checked=true;
}
};
oBtn2.onclick=function(){ //不选
for(var i=0; i<oInp.length ; i++){
oInp[i].checked=false;
}
};
oBtn3.onclick=function(){ //反选
for(var i=0; i<oInp.length ; i++){
if(oInp[i].checked==true){
oInp[i].checked=false;
}
else{
oInp[i].checked=true;
}
}
};
};
</script>
</head>
<body>
<input id="Btn1" type="button" value="全选" /><br />
<input id="Btn2" type="button" value="不选" /><br />
<input id="Btn3" type="button" value="反选" /><br />
<div id="Ben">
<input type="checkbox" /><br />
<input type="checkbox" /><br /> <!--复选框 checked 选中-->
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
<input type="checkbox" /><br />
</div>
javascript 简单的选项卡
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#999966; display:none; color:#000000;}
</style>
<script>
window.onload=function(){
var Div=document.getElementById('div1');
var aBtn=Div.getElementsByTagName('input');
var aDiv=Div.getElementsByTagName('div');
for(var i=0; i<aBtn.length; i++){
aBtn[i].index=i; // 记录
aBtn[i].onmouseover=function (){ // 移入事件
for( var i=0; i<aBtn.length; i++){
aBtn[i].className=''; // 清空
aDiv[i].style.display="none";
};
this.className='active'; // 当前样式
aDiv[this.index].style.display='block';
};
}
};
</script>
</head>
<body>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容22222222</div
<div>这是是内容3333333</div>
</div>
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#ccc; display:none;}
</style>
<script>
window.onload=function(){ // 构造函数:window.onload=
new TaWny('div1'); // 创建对象:TaWny('div1')传参
};
function TaWny(id){ // 构造函数:
var _this = this; //传参 找到 this
var oDiv=document.getElementById(id); //接收 TaWny('div1') 函数的参数
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0; i<this.aBtn.length; i++){
this.aBtn[i].index=i;
this.aBtn[i].onmouseover=function(){ //函数 _this.ofclick(this);
_this.getonmouse(this); //传参 找到 this
}; // 面向对象:函数不要嵌套
}
};
TaWny.prototype.getonmouse=function (aBtn){ // 用prototype原型 使函数变成方法
for( var i=0; i<this.aBtn.length; i++){
this.aBtn[i].className=''; //清空
this.aDiv[i].style.display="none";
}
aBtn.className='active'; //样式
this.aDiv[aBtn.index].style.display='block';
};
</script>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容222222</div>
<div>这是是内容3333</div>
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#ccc; display:none;}
</style>
<script>
window.onload=function(){ // 构造函数:window.onload=
new TaWny('div1'); // 创建对象:TaWny('div1')传参
};
function TaWny(id){ // 构造函数:
var _this = this; //传参 找到 this
var oDiv=document.getElementById(id); //接收 TaWny('div1') 函数的参数
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0; i<this.aBtn.length; i++){
this.aBtn[i].index=i;
this.aBtn[i].onmouseover=function(){ //函数 _this.ofclick(this);
_this.getonmouse(this); //传参 找到 this
}; // 面向对象:函数不要嵌套
}
};
TaWny.prototype.getonmouse=function (aBtn){ // 用prototype原型 使函数变成方法
for( var i=0; i<this.aBtn.length; i++){
this.aBtn[i].className=''; //清空
this.aDiv[i].style.display="none";
}
aBtn.className='active'; //样式
this.aDiv[aBtn.index].style.display='block';
};
</script>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容222222</div>
<div>这是是内容3333</div>
javascript 经典案例 面向对象的选项卡
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#ccc; display:none;}
</style>
<script>
window.onload=function(){ // 构造函数:window.onload=
new TaWny('div1'); // 创建对象:TaWny('div1')传参
};
function TaWny(id){ // 构造函数:
var _this = this; //传参 找到 this
var oDiv=document.getElementById(id); //接收 TaWny('div1') 函数的参数
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0; i<this.aBtn.length; i++){
this.aBtn[i].index=i;
this.aBtn[i].onmouseover=function(){ //函数 _this.ofclick(this);
_this.getonmouse(this); //传参 找到 this
}; // 面向对象:函数不要嵌套
}
};
TaWny.prototype.getonmouse=function (aBtn){ // 用prototype原型 使函数变成方法
for( var i=0; i<this.aBtn.length; i++){
this.aBtn[i].className=''; //清空
this.aDiv[i].style.display="none";
}
aBtn.className='active'; //样式
this.aDiv[aBtn.index].style.display='block';
};
</script>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容222222</div>
<div>这是是内容3333</div>
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#ccc; display:none;}
</style>
<script>
window.onload=function(){ // 构造函数:window.onload=
new TaWny('div1'); // 创建对象:TaWny('div1')传参
};
function TaWny(id){ // 构造函数:
var _this = this; //传参 找到 this
var oDiv=document.getElementById(id); //接收 TaWny('div1') 函数的参数
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0; i<this.aBtn.length; i++){
this.aBtn[i].index=i;
this.aBtn[i].onmouseover=function(){ //函数 _this.ofclick(this);
_this.getonmouse(this); //传参 找到 this
}; // 面向对象:函数不要嵌套
}
};
TaWny.prototype.getonmouse=function (aBtn){ // 用prototype原型 使函数变成方法
for( var i=0; i<this.aBtn.length; i++){
this.aBtn[i].className=''; //清空
this.aDiv[i].style.display="none";
}
aBtn.className='active'; //样式
this.aDiv[aBtn.index].style.display='block';
};
</script>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容222222</div>
<div>这是是内容3333</div>
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#ccc; display:none;}
</style>
<script>
window.onload=function(){ // 构造函数:window.onload=
new TaWny('div1'); // 创建对象:TaWny('div1')传参
};
function TaWny(id){ // 构造函数:
var _this = this; //传参 找到 this
var oDiv=document.getElementById(id); //接收 TaWny('div1') 函数的参数
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0; i<this.aBtn.length; i++){
this.aBtn[i].index=i;
this.aBtn[i].onmouseover=function(){ //函数 _this.ofclick(this);
_this.getonmouse(this); //传参 找到 this
}; // 面向对象:函数不要嵌套
}
};
TaWny.prototype.getonmouse=function (aBtn){ // 用prototype原型 使函数变成方法
for( var i=0; i<this.aBtn.length; i++){
this.aBtn[i].className=''; //清空
this.aDiv[i].style.display="none";
}
aBtn.className='active'; //样式
this.aDiv[aBtn.index].style.display='block';
};
</script>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容222222</div>
<div>这是是内容3333</div>
<style>
#div1 input{ background:white;}
#div1 input.active{ background:yellow;}
#div1 div{ width:200px; height:200px; background:#ccc; display:none;}
</style>
<script>
window.onload=function(){ // 构造函数:window.onload=
new TaWny('div1'); // 创建对象:TaWny('div1')传参
};
function TaWny(id){ // 构造函数:
var _this = this; //传参 找到 this
var oDiv=document.getElementById(id); //接收 TaWny('div1') 函数的参数
this.aBtn=oDiv.getElementsByTagName('input');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0; i<this.aBtn.length; i++){
this.aBtn[i].index=i;
this.aBtn[i].onmouseover=function(){ //函数 _this.ofclick(this);
_this.getonmouse(this); //传参 找到 this
}; // 面向对象:函数不要嵌套
}
};
TaWny.prototype.getonmouse=function (aBtn){ // 用prototype原型 使函数变成方法
for( var i=0; i<this.aBtn.length; i++){
this.aBtn[i].className=''; //清空
this.aDiv[i].style.display="none";
}
aBtn.className='active'; //样式
this.aDiv[aBtn.index].style.display='block';
};
</script>
<div id="div1">
<input class="active" type="button" value="选项1" />
<input type="button" value="选项2" />
<input type="button" value="选项3" />
<div style="display:block;" >这是容11111111</div>
<div>这是是内容222222</div>
<div>这是是内容3333</div>
分享到:
相关推荐
python学习资源
jfinal-undertow 用于开发、部署由 jfinal 开发的 web 项目
基于Andorid的音乐播放器项目设计(国外开源)实现源码,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。
python学习资源
python学习资源
python学习一些项目和资源
【毕业设计】java-springboot+vue家具销售平台实现源码(完整前后端+mysql+说明文档+LunW).zip
HTML+CSS+JavaScarip开发的前端网页源代码
python学习资源
【毕业设计】java-springboot-vue健身房信息管理系统源码(完整前后端+mysql+说明文档+LunW).zip
成绩管理系统C/Go。大学生期末小作业,指针实现,C语言版本(ANSI C)和Go语言版本
1_基于大数据的智能菜品个性化推荐与点餐系统的设计与实现.docx
【毕业设计】java-springboot-vue交流互动平台实现源码(完整前后端+mysql+说明文档+LunW).zip
内容概要:本文主要探讨了在高并发情况下如何设计并优化火车票秒杀系统,确保系统的高性能与稳定性。通过对比分析三种库存管理模式(下单减库存、支付减库存、预扣库存),强调了预扣库存结合本地缓存及远程Redis统一库存的优势,同时介绍了如何利用Nginx的加权轮询策略、MQ消息队列异步处理等方式降低系统压力,保障交易完整性和数据一致性,防止超卖现象。 适用人群:具有一定互联网应用开发经验的研发人员和技术管理人员。 使用场景及目标:适用于电商、票务等行业需要处理大量瞬时并发请求的业务场景。其目标在于通过合理的架构规划,实现在高峰期保持平台的稳定运行,保证用户体验的同时最大化销售额。 其他说明:文中提及的技术细节如Epoll I/O多路复用模型以及分布式系统中的容错措施等内容,对于深入理解大规模并发系统的构建有着重要指导意义。
基于 OpenCV 和 PyTorch 的深度车牌识别
【毕业设计-java】springboot-vue教学资料管理系统实现源码(完整前后端+mysql+说明文档+LunW).zip
此数据集包含有关出租车行程的详细信息,包括乘客人数、行程距离、付款类型、车费金额和行程时长。它可用于各种数据分析和机器学习应用程序,例如票价预测和乘车模式分析。
把代码放到Word中,通过开发工具——Visual Basic——插入模块,粘贴在里在,把在硅基流动中申请的API放到VBA代码中。在Word中,选择一个问题,运行这个DeepSeekV3的宏就可以实现在线问答
【毕业设计】java-springboot+vue机动车号牌管理系统实现源码(完整前后端+mysql+说明文档+LunW).zip
【毕业设计】java-springboot-vue交通管理在线服务系统的开发源码(完整前后端+mysql+说明文档+LunW).zip