There are 19 Repeater controls on the homepage of the Student Department website. Tab switching between 6 div blocks.
You can’t write the methods one by one when switching tabs: (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("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 assignment in line 23 uses JQuery's index method. Find the index value of an element of an object in the object.
An official explanation: $('li').index($('#bar')); The index parameter here uses single quotes. It always fails during testing. . Don't know why. Later, the object where $(this) is located is directly defined first: var arra=$("#" ab "a");.
The index can be returned successfully.
The following is one of the Tabs
News li> ;div class="w1bg"> < ;div class="w336" id="ul_tabs">