Jquery 将每个li:eq(1,2,…)更改为for循环

Jquery 将每个li:eq(1,2,…)更改为for循环,jquery,html,Jquery,Html,每个li:eq(0,1,2,3,…i)如何更改为for循环 $(“.section4ulli:eq(0)”。单击(函数(){ $(“.PaNel”).hide(); $(“#表1”).show(); }); $(“.Section4ulli:eq(1)”。单击(函数(){ $(“.PaNel”).hide(); $(“#tab2”).show(); }); $(“.Section4ulli:eq(2)”。单击(函数(){ $(“.PaNel”).hide(); $(“#表3”).show();

每个li:eq(0,1,2,3,…i)如何更改为for循环

$(“.section4ulli:eq(0)”。单击(函数(){
$(“.PaNel”).hide();
$(“#表1”).show();
});
$(“.Section4ulli:eq(1)”。单击(函数(){
$(“.PaNel”).hide();
$(“#tab2”).show();
});
$(“.Section4ulli:eq(2)”。单击(函数(){
$(“.PaNel”).hide();
$(“#表3”).show();
});
$(“.Section4ulli:eq(3)”。单击(函数(){
$(“.PaNel”).hide();
$(“#tab4”).show();
});


根本不需要for循环,使用方法在处理程序中生成
id

$(".section4 ul li").click(function(){
    $(".PaNel").hide();
    $("#tab" + ($(this).index() + 1)).show();
});

或使用方法链接的一个线性代码


根本不需要for循环,使用方法在处理程序中生成
id

$(".section4 ul li").click(function(){
    $(".PaNel").hide();
    $("#tab" + ($(this).index() + 1)).show();
});

或使用方法链接的一个线性代码


@和声尹:很乐意帮忙:)@和声尹:很乐意帮忙:)