The JQuery Index () method uses code _jquery

Source: Internet
Author: User
The homepage of the student section has 19 repeater controls. 6 div block tabs switch.

Do tabs switch can not write the way one by one: (code as follows ...)
Copy Code code 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 ("Div"). attr ("id");
var ulid= "Ul_" +AB;
var arra=$ ("#" +ab+ "a");
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 23 row assignment uses the jquery index method. Finds the index value of an element of an object in this object.
Official One note: $ (' Li '). Index ($ (' #bar '); Here the index argument is in single quotes. Always fails during the test. Don't know why. Later, we define the object of $ (this) directly: Var arra=$ ("#" +ab+ "a");.
You can successfully return the index.
Here is one of the tabs
Copy Code code as follows:

<div class= "Sh_topnew" >
<div class= "W1BG" ></div>
<div id= "Tabs" >
<li><div class= "W1BG" ></div><a href= "list.aspx"? uid=185 "> News dynamic </a><div class=" W1BG "></div></li>
<li><div class= "W1BG" ></div><a href= "list.aspx"? uid=160 "> Group special Work </a><div class=" W1BG "></div></li>
</div>
<div class= "W1BG" ></div></div>
<div class= "w636" >
<div class= "w300" ></div>
<div class= "w336" id= "Ul_tabs" ><ul></ul><ul class= "Nodis" >
<li><a href= "Show.aspx? uid=194&id=6393 "title=" Regiment Dry Training Notice ">[Regiment Dry Training" Regiment dry training notice </a>2010-05-17</li>
<li><a href= "Show.aspx? uid=193&id=6392 "Title=" The Communist Youth League of our school to carry out the main activities of the construction of study atmosphere ">[Pourges activities]" The Communist Youth League of our school construction main activities </a>2010-05-17</li>
</ul></div>
</div>

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.