jQuery implements Tab switching. The simple effect of js code written not long ago by contacting jQ is now written in jQ:
HTML code:
css code:
#sidebar-tab{border:1px solid #ccf;margin-bottom:1.5em;overflow :hidden;}
#tab-title h3{color:#666;font-size:15px;font-weight:400;}
#tab-title .selected{color:#356aa0;border-bottom: 0px;} /*Style when the title is selected*/
#tab-title span{padding:5px 9px 5px 10px;border:1px solid #ccf;border-right:0px;margin-left:-1px;cursor :pointer;}
#tab-content .hide{display:none;} /*The first piece of content is displayed by default, and the rest are hidden*/
#tab-content ul{padding:5px 10px;overflow:hidden ;}
#tab-content ul li{padding-top:5px;height:20px;}
jQ code:
It is very convenient to write with jQ; first find the child element in the ID to add the event click introduces the function; after finding the sibling element, removeClass(); let other sibling elements display: "none";
The following is the original jQ code:
<script> <br><br>$('#tab-title span').click(function(){ $(this).addClass("selected").siblings().removeClass(); $("#tab-content > ul").slideUp('1500'). eq($('#tab-title span').index(this)).slideDown('1500') <br>}); <br></script>
When you Clicking the current event after triggering the current event will still trigger it; there is no need to trigger the event (this) when clicking the current event;