第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

在切換時更改 url

在切換時更改 url

慕妹3242003 2021-10-21 15:09:31
jQuery(document).ready(function () {    jQuery('.custom-switch').click(function(){        var url = jQuery('.anchr').attr('href');        var src = jQuery('.anchr').attr('data-source');        var type = jQuery('.anchr').attr('data-target');        if(type == 'monthly'){            jQuery('.anchr').attr('href', src);            jQuery('.anchr').attr('data-source', url);            jQuery('.anchr').attr('data-target', 'yearly');        }else{            jQuery('.anchr').attr('href', src);            jQuery('.anchr').attr('data-source', url);             jQuery('.anchr').attr('data-target', 'monthly');        }    });});<div class="switch"><span class="monthly">Billed Monthly</span> <div class="custom-switch" id="undefined"><input class="custom-switch" type="checkbox" id="custom-switch-0"><label for="custom-switch-0"></label></div> <span class="annually">Billed Annually (Save 10%) </span></div><ul><li class="plan__price"><a href="https://www.example.com/india/?amt=7499" data-source=https://www.example.com/india/?amt=6749" data-target="monthly" class="anchr btn btn-primary price-btn" target="_blank" rel="noopener"> Pay Now </a></li></ul>我使用了具有不同網(wǎng)址的兩個立即付款按鈕,切換后兩個按鈕都獲得相同的網(wǎng)址。需要不同的網(wǎng)址,如果我再次為第二個按鈕編寫相同的代碼,但效果不同,那么效果很好jQuery(document).ready(function () {    jQuery('.custom-switch').click(function(){        var url = jQuery('.anchr').attr('href');        var src = jQuery('.anchr').attr('data-source');        var type = jQuery('.anchr').attr('data-target');        if(type == 'monthly'){            jQuery('.anchr').attr('href', src);            jQuery('.anchr').attr('data-source', url);            jQuery('.anchr').attr('data-target', 'yearly');        }else{            jQuery('.anchr').attr('href', src);            jQuery('.anchr').attr('data-source', url);             jQuery('.anchr').attr('data-target', 'monthly');        }    });});
查看完整描述

2 回答

?
明月笑刀無情

TA貢獻1828條經(jīng)驗 獲得超4個贊

假設(shè) 'custom-switch' 類針對你的三個按鈕,你可以試試這個:


jQuery(document).ready(function () {

    jQuery('.custom-switch').click(function(){

        var target = jQuery('.anchr'); // this is less wasteful

        var url = target[0].attr('href'); // notice the indices

        var src = target[0].attr('data-source');

        var type = target[0].attr('data-target');

        if(type == 'monthly'){

            target[1].attr('href', src);

            target[1].attr('data-source', url);

            target[1].attr('data-target', 'yearly');

        }else{

            target[2].attr('href', src);

            target[2].attr('data-source', url); 

            target[2].attr('data-target', 'monthly');

        }

    });

});


查看完整回答
反對 回復(fù) 2021-10-21
  • 2 回答
  • 0 關(guān)注
  • 174 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號