1,

js代码
function ntabs(thisObj,Num)
            {if(thisObj.className == "active")return;  
            var tabObj = thisObj.parentNode.id;  
            var tabList = document.getElementById(tabObj).getElementsByTagName("li");  
            for(i=0; i <tabList.length; i++)
                {if (i == Num)
                    {thisObj.className = "active";  
                    document.getElementById(tabObj+"_cont"+i).style.display = "block";  
                    }
                    else{  
                        tabList[i].className = "normal";  
                        document.getElementById(tabObj+"_cont"+i).style.display = "none";  
                }  
            }  
        }

html:

<div class="hot_news">

<div class="title">
<ul id="mytab1">
<li class="active" onmousemove="ntabs(this,0);">医院动态</li>
<li class="normal" onmousemove="ntabs(this,1);">媒体报道</li>
<li class="normal" onmousemove="ntabs(this,2);">权威技术</li>
</ul>
</div>
<div class="content">
<div class="cont_01" id="mytab1_cont0">
<div><img src="/static/images/2z_04.jpg" width="130px;" height="125px;" />
<h3>新年3重礼,蜕变迎新春</h3>
<p>新的一年即将到来,在这个冬天里,你却惶恐不安,只因为白斑的困扰。白癜风对患者的学习工作、社...[<a style="color:#c13145; " href="#">详情</a>]</p></div>
<div>
<ul>
<li><img src="/static/images/2z_06.jpg" /><a href="#">新年3重礼,蜕变迎新春</a></li>
<li><img src="/static/images/2z_06.jpg" /><a href="#">新年3重礼,蜕变迎新春</a></li>
<li><img src="/static/images/2z_06.jpg" /><a href="#">新年3重礼,蜕变迎新春</a></li>
<li><img src="/static/images/2z_06.jpg" /><a href="#">新年3重礼,蜕变迎新春</a></li>
<li><img src="/static/images/2z_06.jpg" /><a href="#">新年3重礼,蜕变迎新春</a></li>
</ul>
</div>
</div>
<div class="cont_02 none" id="mytab1_cont1"></div>
<div class="cont_03 none" id="mytab1_cont2"></div>
</div>

</div>

css:

*{ margin: 0 auto; text-align: center; list-style: none; font-family: 微软雅黑; padding: 0; }
ul li{list-style:none;}
.hot_news{ float:left; width:360px; margin-right:15px; height:345px;}
.hot_news .title{ height:45px; widows:360px; margin-bottom:10px;}
.hot_news .title ul li{ float:left; width:120px; height:45px; line-height:45px; background:#eee;}
.hot_news .title .active{ background:#c13145; color:#fff; cursor:pointer;}
.hot_news .content img{ float:left; margin-right:10px;}
.hot_news .content h3{ font-weight:normal; height:35px; line-height:35px; display:block;}
.hot_news .content p{ line-height:24px; font-size:14px; text-indent:2em; text-align:left;}
.hot_news .content ul{ margin-top:5px;}
.hot_news .content ul li{ height:30px; line-height:30px; width:340px; overflow:hidden; text-align:left;}
.hot_news .content ul li img{ display:block; padding-top:11px;}
.hot_news .content ul li a{ color:#888;}
.hot_news .content ul li a:hover{ color:#c13145;}

2,
$(document).ready(function(){

var $tab_li = $('.tab ul li');

$tab_li.hover(function(){

$(this).addClass('selected').siblings().removeClass('selected');

var index = $tab_li.index(this);

$('div.tab_box > div').eq(index).show().siblings().hide();

});

});

tab切换的两段js

js切换换class的更多相关文章

  1. php网页切图/js切图

    PhantomJS抓取网站页面信息以及网站截图 http://phantomjs.org/download.html PHP imagegrabscreen和imagegrabwindow(截取网站缩 ...

  2. 独辟蹊径:逆推Krpano切图算法,实现在浏览器切多层级瓦片图

    前言 此文我首发于CSDN(所以里面的图片有它的水印) 趁着隔离梳理一下之前做的一个有用的功能:在浏览器中去切割多分辨率瓦片图 这是一个有趣的过程,跟我一起探索吧 阅读本文需具备前置知识:对krpan ...

  3. jsp+springmvc实现文件上传、图片上传和及时预览图片

    1.多文件上传:http://blog.csdn.net/a1314517love/article/details/24183273 2.单文件上传的简单示例:http://blog.csdn.net ...

  4. rc.sysinit 解析

    $# :它可抓出 positional parameter 的數量,即脚本后面的参数有几个 $@和$*表示全部参数,但不包含脚本名,即$0,如果在command line上跑 my.sh p1 “p2 ...

  5. linux系统配置之开机启动过程(centos)

    1.开机流程如下: 2.BIOS BIOS是英文"Basic Input Output System"的缩略词,直译过来后中文名称就是"基本输入输出系统".其实 ...

  6. 基于HTML5和JS实现的切水果游戏

    切水果游戏曾经是一款风靡手机的休闲游戏,今天要介绍的就是一款网页版的切水果游戏, 由JavaSript和HTML5实现,虽然功能和原版的相差太大,但是基本的功能还是具备了,还是模仿的挺逼真,有一定的J ...

  7. vue基于video.js实现视频播放暂停---切图网

    切图网是最早致力于PSD2HTML切图等web前端外包服务的,随着前端技术的更新迭代,现在也已经全面投入了vue的浪潮了,下面是vue中实现视频播放的方法. vue.js中引入video视频播放器 m ...

  8. 在vue中继续使用layer.js来做弹出层---切图网

    layer.js是一个方便的弹出层插件,切图网专注于PSD2HTML等前端切图多年,后转向Vue开发.在vue开发过程中引入layer.js的时候遇到了麻烦.原因是layer.js不支持import导 ...

  9. [开发笔记]-页面切图、CSS前端设计、JS

    这两天在学习页面的切图,样式设计,把学习过程中注意的地方记录下来. 一. input输入框点击时去掉外边框 一般在IE,firefox下,设置 border:0 none; 即可.但在chrome下, ...

随机推荐

  1. hdu 4750 Count The Pairs(并查集)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4750 代码: #include<cstdio> #include<cstring&g ...

  2. mysql 导出,导入数据

     导出     加-d代表只导出表结构 命令行下具体用法如下:  mysqldump -u用户名 -p密码 -d 數據库名 表名 脚本名; 1.导出数据库为dbname的表结构(其中用户名为root, ...

  3. Oracle分页查询SQL实现

    首先看SQL 怎么写 select * from ( select a.*,ROWNUM rn from ( 最底层查询语句 ) a where ROWNUM <= #{endCol} ) wh ...

  4. ng-repeat 遍历同值数组导致的报错

    http://blog.csdn.net/tyust512/article/details/50370624

  5. cocos2d与cocos2d-X中的draw和update

    像其它的游戏引擎一样,我们有两个不同的方法来完成draw和update. 1: Draw:每一个CCNode都有一个draw方法,每一帧都会调用.我们只在这个方法里做描绘的事情. 2: Update: ...

  6. LeetCode——Linked List Cycle

    Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...

  7. Java实现平衡二叉树(AVLTree)的构建

    近期在学习数据结构上关于平衡二叉树的知识,看了严老师的思路,感觉用java写出递归的构建方式有点困难,由于当中的递归须要把引用传进去,所以感觉是要实现起来比較麻烦,所以就首先想到使用非递归的方式来实现 ...

  8. mysql优化21条

    今天一个朋友向我咨询怎么去优化 MySQL,我按着思维整理了一下,大概粗的可以分为21个方向. 还有一些细节东西(table cache, 表设计,索引设计,程序端缓存之类的)先不列了,对一个系统,初 ...

  9. 廖雪锋笔记2:list,tuble

    list:元素值不固定,元素类型不固定 apend(xx) insert(INDEX,xx) pop(index) 索引元素: [0] [1] [2] [-1] [-2] LIST,TUBLE变量值是 ...

  10. hadoop文件的序列化

    目录 1.为什么要序列化? 2.什么是序列化? 3.为什么不用Java的序列化? 4.为什么序列化对Hadoop很重要? 5.Hadoop中定义哪些序列化相关的接口呢? 6.Hadoop 自定义Wri ...