Home >Web Front-end >JS Tutorial >jquery implements super simple TAB tab effect code_jquery
The example in this article describes the implementation of ultra-concise TAB tab effect code using jquery. Share it with everyone for your reference. The details are as follows:
This is a super simple TAB tab. I personally think it is a bit too simple and I am not used to it. It would be better to beautify it. In fact, it is better to add a background color to the clicked TAB to distinguish it.
Let’s take a look at the screenshots of the running effect:
The online demo address is as follows:
http://demo.jb51.net/js/2015/jquery-easy-tab-cha-menu-codes/
The specific code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>超简洁的TAB选项卡</title> <style> body {font:normal 12px/20px simsun; margin:0 auto; padding:0;} * {margin: 0px; padding: 0px;} h4{font-size:14px;} h5{font-size:12px;} img {border:none;} ul,li{list-style-type:none;} a{text-decoration:none;} a:link{text-decoration:none;} a:hover{text-decoration:underline; color:#ffae00;} .menu li{width:60px; height:30px; text-align:center; line-height:30px; float:left; cursor:pointer;} .menu li:hover, .menu li.on{color:#f00;} .cont{width:180px; height:100px; border:1px solid #666666; clear:both;} </style> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".menu li").click(function(){ var Num=$(this).index("li"); $(".menu li").removeClass("on").eq(Num).addClass("on"); $(".cont").hide().eq(Num).show(); }); }); </script> </head> <body> <div class="tab"> <ul class="menu"> <li class="on">北欧之旅</li> <li>音乐维也纳</li> <li>天堂瑞士</li> </ul> <div class="cont">北欧之旅</div> <div class="cont" style="display:none;">音乐维也纳</div> <div class="cont" style="display:none;">天堂瑞士</div> </div> </body> </html>
I hope this article will be helpful to everyone’s jquery programming design.