JavaScript插件制作-tab选项卡
JavaScript插件制作练习-鼠标划过选项卡切换图片
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
* {
margin: 0;
padding: 0;
} body {
background: #353131;
} .warp {
position: relative;
top: 50px;
left: 25%;
} ul {
list-style: none;
} ul .warp-li {
float: left;
width: 100px;
height: 40px;
line-height: 40px;
background: #000;
opacity: .3;
color: #fff;
text-align: center;
} ul .warp-li:hover {
background: aquamarine;
color: #000000;
opopacity: 1;
} ul::after {
display: block;
content: "";
clear: both;
} .box {
position: absolute;
left: 0;
top: 40px;
display: none;
} .box img {
width: 500px;
height: 300px;
} #show {
display: block;
} #on {
background: aquamarine;
color: #000;
opopacity: 1;
}
</style>
</head> <body>
<div class="warp">
<ul>
<li class="warp-li" id="on">首页</li>
<li class="warp-li">动漫</li>
<li class="warp-li">游戏</li>
<li class="warp-li">生活</li>
<li class="warp-li">直播</li>
</ul>
<div class="box" id="show">
<img src="img/1.jpg" />
</div>
<div class="box">
<img src="img/18d8bc3eb13533fa3110518aadd3fd1f40345bf4.jpg" />
</div>
<div class="box">
<img src="img/359b033b5bb5c9eab33999fed739b6003bf3b3e1.jpg" />
</div>
<div class="box">
<img src="img/ce4a8e8065380cd7fd58a3eaa944ad3459828123.jpg.png" />
</div>
<div class="box">
<img src="img/timg.jpg" />
</div> </div>
<script type="text/javascript">
(function(window) {
var maxTab = function(tabLen, showLen, tabLenId, showLenId) {
this.tabLen = tabLen;
this.showLen = showLen;
this.tabLenId = tabLenId; //选项卡id
this.showLenId = showLenId; //显示区域id
this.show();//调用切换图片的方法
}
maxTab.prototype = {
constructor: maxTab,
show: function() {
var _this = this; //这里的this是指向maxTab的,function会建里一个作用域所以要保留
var tabLen = document.getElementsByClassName(this.tabLen);
var showLen = document.getElementsByClassName(this.showLen);
var index = 0;
for(var i = 0; i < tabLen.length; i++) {
tabLen[i].setAttribute("index", i);
for(var j = 0; j < tabLen.length; j++) {
tabLen[i].onmouseover= function() {
_this.reset(tabLen);
_this.reset(showLen);
this.id = _this.tabLenId;
index = this.getAttribute("index");
showLen[index].id = _this.showLenId;
}
}
}
},
//格式化id
reset: function(obj) {
for(var i = 0; i < obj.length; i++) {
obj[i].removeAttribute("id");
}
}
}
window.maxTab = maxTab;
})(window) //插件调用
var am = new maxTab("warp-li", "box", "on", "show");
</script>
</body> </html>
JavaScript插件制作-tab选项卡的更多相关文章
- :target伪类制作tab选项卡
:target伪类的作用是突出显示活动的HTML锚,下面是一个简单的例子: HTML代码: <div> <a href="#demo1">点击此处</ ...
- 原生javascript 改写的tab选项卡
<!--css部分--> <style> *{ margin: 0; padding: 0; } ul,li{ list-style: none } .tabbox{ widt ...
- 使用jQuery开发tab选项卡插件
为了复习巩固jQuery的插件开发.HTML和CSS方面的知识,做了一个简单的tab选项卡插件,简单记录一下开发.使用的过程,以备日后使用. 一.插件效果 tab选项卡插件常用的功能均已实现,包括:动 ...
- 微信小程序的wx-charts插件-tab选项卡
微信小程序的wx-charts插件-tab选项卡 效果: //index.js var wxCharts = require('../../utils/wxcharts-min.js'); const ...
- 微信小程序swiper制作内容高度不定的tab选项卡
微信小程序利用swiper制作内容高度不定的tab选项卡,不使用absolute定位,不定高度,由内容自由撑开主要思路是获取内容区的高度来给swiper动态设置值 .wxml <view cla ...
- 使用jQuery开发tab选项卡插件(可以右键关闭多个标签)
在前一篇“使用jQuery开发tab选项卡插件”的基础上添加了tab标签右键关闭菜单功能,菜单主要包括:关闭当前标签.关闭左侧标签.关闭右侧标签.关闭其他.关闭全部. 一.插件效果 二.实现思路 为w ...
- javascript插件制作学习-制作步骤
原生JavaScript插件开发学习 自己制作的demo大家可以看下https://www.cnblogs.com/zimengxiyu/p/9814889.html 插件制作步骤: (一)构造函数 ...
- bootstrap 支持的JavaScript插件
一次性导入: Bootstrap提供了一个单一的文件,这个文件包含了Bootstrap的所有JavaScript插件,即bootstrap.js(压缩版本:bootstrap.min.js). 具体使 ...
- Bootstrap JavaScript插件
在bs3.X中,提供了12种JavaScript插件,分别是:动画过渡(Transition).模态弹窗(Modal).下拉菜单(Dropdown).滚动侦测(Scrollspy).选项卡(Tab ...
随机推荐
- Java中创建的对象多了,必然影响内存和性能
1, Java中创建的对象多了,必然影响内存和性能,所以对象的创建越少越好,最后还要记得销毁.
- 数据库or、in、<>、>=、<=、butween区别
操作前先关闭数据库缓存 #创建测试的test表 DROP TABLE IF EXISTS test; CREATE TABLE test( `id` ) NOT NULL, `name` ) DEFA ...
- 勒索病毒[recoverydata54@cock.li].harma,这样恢复文件。
还没有从搬新家的喜悦中恢复回来,突然有一天发现,自己的1T的硬盘的历史遗迹里面的文件都不能打开了.尤其是孩子们的珍贵照片. 这可让我着急了好几天.过了几天我才知道,原来是有天晚上,4周岁的儿子自己不知 ...
- mysql中有条件的插入语句
今天在参加笔试的过程中,看到一道题,大概意思就是说,当满足了条件就执行插入语句,当时就蒙了,之前从来都没有考虑过满足条件才插入的情况,所以一直都是这样写的 insert into table_name ...
- 启动web项目报错:The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone.
解决: 在application.properties配置文件中的添加标红部分 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/miaosha?se ...
- html/form表单常用属性认识
1.form表单常用属性练习 <style> .form1 { margin: auto; height: 900px; width: 500px; text-align: center; ...
- MySQL--高性能MySQL笔记一
链接管理与安全性: 每个客户端连接都在服务器进程中拥有一个线程. MySQL5.5以及更新的版本提供了一个API,支持线程池插件,可以使用池中少量的线程服务大量的链接. 认证基于用户名.密码和原始主机 ...
- Delphi BitBtn组件
- kernel module insmod错误
kernel模块配置 Enable loadable module support 打开可加载模块支持,如果打开它则必须通过"make modules_install"把内核模块安 ...
- 六,k8s集群service资源
目录 Service简介 ClusterIP Headless(无头service) NodePort Service简介 service的基本说明: Service 是作用于客户端可服务端(Pod) ...