亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jq tab切換問題?

jq tab切換問題?

三國紛爭 2018-08-10 09:10:40
 $(".test li").click(function() {        var _index = $(this).index();         $('.test li' + ":eq(" + _index + ")").addClass('on')     });//我想點擊01 所有01都需要加上on//代碼需要如何修改 謝謝//解決方案$('.test .bd .item:first-child').show();$(".test li").click(function() {    var _index = $(this).index() + 1;    var textLi = '.test li';    $('.test li' + ":nth-child(" + _index + ")").addClass('on').siblings().removeClass('on');     $('.test .bd .item' + ":nth-child(" + _index + ")").show().siblings().hide();});
查看完整描述

1 回答

?
一只斗牛犬

TA貢獻1784條經驗 獲得超2個贊

換個思路

<ul class="test">    <li class="one">
    ...
    ...</ul><ul class="test">    <li class="one">
    ...
    ...</ul><ul class="test">    <li class="one">
    ...
    ...</ul>

$(".test li").click(function() {        var className = $(this).attr('class');
        $("." + className).addClass('on');
});


查看完整回答
反對 回復 2018-09-21
  • 1 回答
  • 0 關注
  • 577 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號