[Jquery] tabs tab switch effect (jquery Version)

Source: Internet
Author: User

I wrote one beforeTabs tab switch EffectBut it was written using native Javascript. Recently I am studying jquery. Today I have taken the time to rewrite this effect with jquery.

As follows:

HtmlCodeAs follows:

 <!  Doctype html  >  <  Html  Lang  = "En-us"  >  <  Head  >      < Meta  Charset  = "UTF-8"  />      <  Title  > Tab (for jquery) </  Title  >      <  Link  REL  = "Stylesheet"  Type  = "Text/CSS"  Href = "CSS/base.css"  Media  = "All"  />      <  Style  Type  = "Text/CSS"  >  . Tabs  {  Width  :  500px ;  Margin  :  100px auto  ;  }  . Tabs_menu  {  Font-size  :  0  ; }  . Tabs_menu  {  Padding  :  5px  ;  Border  :  1px solid blue  ;  Font-size :  12px  ;  Margin-left  :  10px  ;  Background  :  # Ececec  ;  Float :  Left  ;  }  . Tabs_menu. Selected  {  Background  :  White  ;  Border-bottom  : 1px solid white  ;  Position  :  Relative  ;  }  . Tabs_content  {  Border  : 1px solid blue  ;  Padding  :  10px  ;  Margin-top  :  -1px  ;  }      </ Style  >  </  Head  >  <  Body  >      <  Div  Class  = "Tabs"  >          <  H2  Class  = "Tabs_menu Clearfix" >              <  A  Href  = "Javascript :;"  Class  = "Selected"  > News </  A  >              <  A  Href  = "Javascript :;"  > Sports </ A  >              <  A  Href  = "Javascript :;"  > Entertainment </  A  >          </  H2  >          <  Div  Class  = "Tabs_content_wrap" >              <  Div  Class  = "Tabs_content"  > News news </  Div  >              <  Div  Class  = "Tabs_content hide"  > Sports </  Div >              <  Div  Class  = "Tabs_content hide"  > Entertainment entertainment </  Div  >          </  Div  >      </  Div  >  </  Body >  </  Html  >  <  Script  Type  = "Text/JavaScript"  SRC  = "JS/jquery. Min. js"  > </  Script  >  <  Script  Type  = "Text/JavaScript" >  VaR  $ Menu  =  $ (  '  . Tabs>. tabs_menu  '  ); $ Menu. Click (  Function  () {$ (  This ). Addclass (  '  Selected  '  ). Siblings (). removeclass (  '  Selected  '  );  VaR  Index =  $ Menu. Index (  This  ); $ (  '  . Tabs_content_wrap>. tabs_content  '  ). Eq (INDEX). Show (). siblings (). Hide ();});  </  Script  > 

TIPS: If jquery is used, you need to introduce the jquery library.

PS: The above are some of the effects I have learned through jquery.

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.