<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tab-oop</title>
</head>
<style>
#div1 div{
width: 200px;
height: 200px;
border: 1px solid red;
background-color: #ccc;
display: none;
}
button{
background: white;
}
#div1 button.active{
background: yellow;
}
</style>
<body> <div id="div1">
<button class="active">aaa</button>
<button>bbb</button>
<button>ccc</button>
<div style="display: block;">aaa</div>
<div>bbb</div>
<div>ccc</div>
</div> </body>
<script>
window.onload=function(){
new TabSwitch('div1');
}
function TabSwitch(id){
var _this=this;
var oDiv=document.getElementById(id);
this.aBtn=document.getElementsByTagName('button');
this.aDiv=oDiv.getElementsByTagName('div');
for(var i=0;i<this.aBtn.length;i++){
this.aBtn[i].index=i;
this.aBtn[i].onclick=function(){
_this.fnClick(this);
}
}
} TabSwitch.prototype.fnClick=function(oBtn){
for(var i=0;i<this.aBtn.length;i++){
this.aBtn[i].className='';
this.aDiv[i].style.display='none';
}
oBtn.className='active';
this.aDiv[oBtn.index].style.display='block';
}
</script>
</html>

OOP学习的更多相关文章

  1. oop学习 计算器类的规划

    类的学习 题目要求 采取面向对象的方法,四则运算自动出题软件,根据需求可以划分为几个类?每个类具有什么属性?每个类具有什么行为? 类与类之间是如何进行协作的?谁给谁发送消息?谁持有谁的引用? 该自动出 ...

  2. ruby oop学习

    class Man def initialize(name,age) @name=name @age=age end def sayName puts @name end def sayAge put ...

  3. OOP 学习笔记汇总

    1.1 引用 1.2 const关键字 1.3 动态内存分配 1.4 内联函数和重载函数函数参数缺省值 1.5 类和对象的基本概念与用法1 2.1 类和对象的基本概念2

  4. OOP复习笔记

    /*OOP相关的代名词不做讲解*/ OOP的三大特征: 封装 - 继承 - 多态 -----------------------------------目录---------------------- ...

  5. 【LabVIEW技巧】LabVIEW OOP怎么学

    前言 有很多人对LabVIEW OOP存在比较极端的看法,大致分为两类: 1. 绝对否定派认为LabVIEW OOP只不过是LabVIEW为了追求时髦,在面向过程的基础上用簇做了一些特性,实际上完全不 ...

  6. Object Pascal对象模型中构造函数之研究

    http://www.delphi2007.net/delphiblog/html/delphi_2004511950333715.html 前言 近期,一直在使用 C++ 与 Object Pasc ...

  7. css重构之旅

    css重构之旅 >前言: 今年我大一,马上就要大二了.从高三毕业暑假到大学的这一年马上过去,马上迎来大二生活学习前端也有将近一年了.一昧去追求那些视觉的效果和相对高端和新颖的技术,反而忽略了最基 ...

  8. Python 面向对象4-继承

    #!/usr/bin/env python # -*- coding:utf-8 -*- # 作者:Presley # 邮箱:1209989516@qq.com # 时间:2018-08-05 # O ...

  9. Python 面向对象3-类变量与实例变量

    #!/usr/bin/env python # -*- coding:utf-8 -*- # 作者:Presley # 邮箱:1209989516@qq.com # 时间:2018-08-05 # O ...

随机推荐

  1. NYOJ 483 Nightmare 【广搜】+【无标记】

    版权声明:长风原创 https://blog.csdn.net/u012846486/article/details/31032479 Nightmare 时间限制:1000 ms  |  内存限制: ...

  2. 无损压缩PNG工具

    http://nullice.com/archives/1998 http://nullice.com/archives/1998 http://nullice.com/limitPNG/ https ...

  3. InvokeRequired和Invoke(转)

    C#中禁止跨线程直接访问控件,InvokeRequired是为了解决这个问题而产生的,当一个控件的InvokeRequired属性值为真时,说明有一个创建它以外的线程想访问它.此时它将会在内部调用ne ...

  4. ubuntu设置开机默认进入字符界面方法 ubuntu 12.04 桌面版关闭图形界面(转)

    ubuntu 12.04 桌面版关闭图形界面 注意]改GRUB 的配置文件(不建议直接改 grub.conf) file:/etc/default/grub GRUB_CMDLINE_LINUX_DE ...

  5. C# 泛型类和泛型方法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. 【python】try...except...后中断程序继续运行

  7. PerformEraseBackground 擦除背景(ThemeServices)

    PerformEraseBackground 擦除背景的简单方法(外带ThemeServices例子) 在查这个函数的时候,顺便看到了有趣的代码. 怎么使用 Themes . unit Unit2; ...

  8. HTML和CSS的静态页面

    链接:https://pan.baidu.com/s/1fGajigyQJDLIHqxJn2LXsQ 提取码:7sry 复制这段内容后打开百度网盘手机App,操作更方便哦 设计思路,把网页分成几个模块 ...

  9. webservice的model层命名空间不同的问题

        [XmlType(Namespace = "http://tempuri.org/MyClass4")]     [XmlRoot(Namespace = "ht ...

  10. 数据库返回刚插入记录的ID

    --创建数据库和表create database MyDataBaseuse MyDataBase create table mytable(id int identity(1,1),name var ...