<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>tab栏</title> <script src="jquery-3.2.1.min.js"></script> <style> .box{ font-size: 14px; } .tab{ width: 538px; border:1px solid #ccc; height:36px; background-image:url('tabbg.png'); background-repeat: repeat-x; } .tab div{ line-height: 37px; font-size: 14px; color:#333; float: left; padding:0 16px; border-right: 1px solid #ccc; } .tab a{ line-height: 35px; color:#333; text-decoration: none; display: block; float: right; margin-right: 12px; } .tab .on{ background-color: white; font-weight: bold; } .content{ width: 538px; border:1px solid #ccc; border-top: none; overflow: hidden; } .leftside{ width: 80px; float: left; } .middleside{ width: 360px; float: left; } .rightside{ width: 98px; float: left; } </style> </head> <body> <div> <div> <div id="article" data-index='one'>技术文章</div> <div id="source" data-index='two'>网站源码</div> <div id="library" data-index='three'>php类库</div> <div id="metarial" data-index='four'>学习资料</div> <a href="#">更多下载>></a> </div> <div id="one" style = "display:block;"> <div> <div>H5教程</div> <div>H5教程</div> <div>html教程</div> <div>html教程</div> </div> <div> <div> 111如何解决HTML5微信播放全屏问题 </div> <div> 111如何解决HTML5微信播放全屏问题 </div> <div> 111如何解决HTML5微信播放全屏问题 </div> <div> 111如何解决HTML5微信播放全屏问题 </div> </div> <div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> </div> </div> <div id="two" style = "display:none;"> <div> <div>PHP源码</div> <div>PHP源码</div> <div>js源码</div> <div>js源码</div> </div> <div> <div> 222优质商城系统js源码 </div> <div> 222优质商城系统js源码 </div> <div> 222优质商城系统js源码 </div> <div> 222优质商城系统js源码 </div> </div> <div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> </div> </div> <div id="three" style = "display:none;"> <div> <div>PHP类库</div> <div>PHP类库</div> <div>PHP类库</div> <div>PHP类库</div> </div> <div> <div> 333如何解决PHP类库问题 </div> <div> 333如何解决PHP类库问题 </div> <div> 333如何解决PHP类库问题 </div> <div> 333如何解决PHP类库问题 </div> </div> <div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> </div> </div> <div id="four" style = "display:none;"> <div> <div>学习资料</div> <div>学习资料</div> <div>学习资料</div> <div>学习资料</div> </div> <div> <div> 444如何解决学习资料良莠不齐的问题 </div> <div> 444如何解决学习资料良莠不齐的问题 </div> <div> 444如何解决学习资料良莠不齐的问题 </div> <div> 444如何解决学习资料良莠不齐的问题 </div> </div> <div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> <div> 2017-12-11 </div> </div> </div> </div> <script> $(document).ready(function(){ $(".tab div").on('mouseover',function(){ $(".tab div").removeClass('on'); $(this).addClass('on'); $('.content').hide(); $('#'+this.dataset.index).show(); }) }); </script> </body> </html>