复制代码 代码如下:
$(function(){
$(".tabs li").eq(0).css("background","#499AFF");
$(".tabs div").eq(0).show();
$(".tabs>ul>li").click(function(i){
$(this).css("background","#499AFF").siblings().css("background","#ffffff");
$(".tabs div").eq($("li").index(this)).show().siblings("div").hide();
return false;
})
})
演示(请“运行代码”后,刷新一次):
jquery tab *{ padding:0; margin:0; } body{ margin-left:100px; margin-top:100px; } .tabs{ width:250px; height:300px; } .tabs ul{ width:250px; height:28px; } .tabs ul li{ float:left; width:50px; height:28px; color:white; line-height:28px; margin-right:10px; text-align:center; } .tabs ul li a:link,.tabs ul li a:visited{ color:black; } .tabs div{ border:1px solid #499AFF; display:none; } .tabs div a{ display:block; width:250px; text-decoration:none; margin-top:5px; padding-left:10px; } a:link,a:visited{ color:blue; font-size:12px; text-decoration:none; } a:hover{ color:red; } li{ list-style:none; }
- 脚本jb51