Using JS to control the hiding and display of tabs

Source: Internet
Author: User

By using the UL and Div, the display and hiding of tabs is realized by means of jquery.

<form action= "" method= "POST" >
<div>
<ul>
<li><a id= "Atab1" class= "Atab" > Kikikiki </a></li>
<li><a id= "atab2" class= "Atab" > Laptop </a></li>
<li><a id= "atab3" class= "Atab" > Letter and Letter </a></li>
<li><a id= "ATAB4" class= "Atab" > Interest-bearing </a></li>
<li><a id= "atab5" class= "Atab" > Ha ha </a></li>
</ul>
</div>

<div >
<div class= "tab" id= "Tab1" >

</div>
<!--End #tab1--
<div class= "tab" id= "TaB2" >

</div>
<!--End #tab2--
<div class= "tab" id= "Tab3" >

</div>
<!--End #tab3--
<div class= "tab" id= "TAB4" >

</div>
<!--End #tab4--
<div class= "tab" id= "Tab5" >

</div>
<!--End #tab5--
</div>
</form>

<script type= "Text/javascript" >
$ (document). Ready (function (e) {
$ ('. tab '). each (function (e) {
if (E = = 0)
$ (this). Show ();//The first time the load is first displayed by default
Else
$ (this). Hide ();
});
})
Bind each Atab to an order-click event
$ ('. Atab '). Bind (' click ', function () {
$ ('. tab '). hide ();//Hides all content
var attr = $ (this). attr (' id ');
var id = ' # ' + attr.substring (1, attr.length);
$ (ID). Show ();//Display the currently selected item
});
</script>

Using JS to control the hiding and display of tabs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.