Use the JQueryindex () method with code _ jquery

Source: Internet
Author: User
There are many ways to select a card switch. There is no definite method. The charm of a program lies in the fact that there are countless [Methods] to implement a [Result. The home page of the student's website has 19 Repeater controls. Switch between the six p blocks.

You cannot write the tabs switch one by one: (the Code is as follows ....)

The Code is as follows:


$ (Function ()
{
$ ("# Tabs a: eq (0), # tabs2 a: eq (0), # dbt_l_t_tabs a: eq (0), # dbt_r_t_tabs a: eq (0) "). addClass ("m_on ");
$ ("# Tabs a: gt (0), # tabs2 a: gt (0), # dbt_l_t_tabs a: gt (0), # dbt_r_t_tabs a: gt (0) "). addClass ("m_out ");
$ ("# Tabs a, # tabs2 a, # dbt_l_t_tabs a, # dbt_r_t_tabs a"). each (function (){
$ (This). mouseover (function (){
If ($ (this). hasClass ("m_out "))
{
Var AB = $ (this). closest ("li"). closest ("p"). attr ("id ");
Var ulid = "ul _" + AB;
Var arra = $ ("#" + AB + "");
Var e = arra. index ($ (this ));
$ ("#" + AB + "a"). removeClass ("m_on"). addClass ("m_out ");
$ (This). removeClass ("m_out"). addClass ("m_on ");
$ ("#" + Ulid + "ul"). hide ();
$ ("#" + Ulid + "ul: eq (" + e + ")"). show ();
}
})
})
})


The index method of JQuery is used to assign values to the 23 rows. Search for the index value of an element of an object in this object.
An official note: $ ('lil'). index ($ ('# bar'); here, the index parameter is enclosed in single quotes. Always fails during the test .. I don't know why. Then, the object where $ (this) is located is defined: var arra = $ ("#" + AB + "");.
You can return the index successfully.
Here is a Tabs

The Code is as follows:





  • News


  • Special Group work







      • [Group Cadre Training] group Cadre Training notice 2010-05-17

      • [Group day activity] the Youth League Committee of our school held the subject activity of Style Building


      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.