<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><BR><html
xmlns="
http://www.w3.org/1999/xhtml"><BR><head><BR><meta
http-equiv="Content-Type" content="text/html; charset=gb2312" /><BR><title>tabs</title><BR></head><BR><script src="js/jquery-1.5.1.min.js"></script><BR><script type="text/javascript" language="javascript"><BR>$(function(){<BR> <BR> $(".tabs ul li").mouseover(function(){<BR> <BR> $(".tabs ul li.current").removeClass("current");//删除li的current类<BR> $(this).addClass("current"); //给当前li增加类;<BR> var index=$(this).index();//获取li的索引号<BR> $(".tabs div.current").removeClass("current");//删除div的current类<BR> $(".tabs div").eq(index).addClass("current"); // 获取li跟div对应的索引号,并且给div添加类 <BR> }); <BR> <BR>});<BR><BR><BR></script><BR><style type="text/css"><BR>.tabs{<BR> width:400px;<BR> height:300px;<BR> border:1px solid #000;<BR>}<BR>.tabs ul {<BR> width:400;<BR> padding:0;<BR> margin:0;<BR>}<BR>.tabs ul li{<BR> width:100px;<BR> height:20px;<BR> padding:5px 0;<BR> list-style-type:none;<BR> text-align:center;<BR> float:left;<BR> background:#09F;<BR>}<BR>.tabs ul li.current{<BR> width:100px;<BR> height:20px;<BR> padding:5px 0;<BR> list-style-type:none;<BR> text-align:center;<BR> float:left;<BR> background:#fff;<BR>}<BR>.tabs div{<BR> clear:both;<BR> width:100%;<BR> height:270x;<BR> display:none;<BR>}<BR>.tabs div.current{<BR> clear:both;<BR> width:100%;<BR> height:270px;<BR> display:block;<BR>}<BR><BR></style><BR><body><BR><BR><div class="tabs"><BR> <ul><BR> <li class="current">1</li><BR> <li>2</li><BR> <li>3</li><BR> <li>4</li><BR> </ul><BR> <div class="current">11</div><BR> <div>22</div><BR> <div>33</div><BR> <div>44</div><BR></div><BR><BR></body><BR></html><BR><BR>