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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用復(fù)選框啟用/禁用按鈕

使用復(fù)選框啟用/禁用按鈕

如果兩個(gè)復(fù)選框都被選中,我需要啟用/禁用按鈕。我想在 knockout.js 中做。我還是個(gè)初學(xué)者。我找到了一個(gè)使用復(fù)選框啟用/禁用按鈕的示例,但這是針對(duì) 1 個(gè)復(fù)選框執(zhí)行的。在我的場(chǎng)景中,我有兩個(gè)復(fù)選框,應(yīng)該選中它們以啟用按鈕。如果未選中任何復(fù)選框,則應(yīng)禁用該按鈕。<input type="checkbox" data-bind="checked: myBoolean" /><button data-bind="enable: myBoolean">My Button</button>ko.applyBindings({ myBoolean: ko.observable(true) });任何幫助或建議將不勝感激。提前致謝
查看完整描述

2 回答

?
至尊寶的傳說(shuō)

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊

你可以

  1. 為另一個(gè)復(fù)選框添加另一個(gè)可觀察對(duì)象

  2. 為按鈕添加一個(gè)計(jì)算的可觀察值,只有當(dāng)兩個(gè)復(fù)選框都被選中時(shí)才返回真(可觀察值是真的)

var test = {?

? myBoolean1: ko.observable(false),

? myBoolean2: ko.observable(false)

};

test.myComputed = ko.computed(function() { return test.myBoolean1() && test.myBoolean2() });


ko.applyBindings(test);

<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>

<input type="checkbox" data-bind="checked: myBoolean1" />

<input type="checkbox" data-bind="checked: myBoolean2" />

<button data-bind="enable: myComputed">My Button</button>


查看完整回答
反對(duì) 回復(fù) 2023-02-24
?
呼喚遠(yuǎn)方

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超11個(gè)贊

您只能使用 CSS 來(lái)完成此操作。除非你需要支持 IE10 或更低版本。


button {

  cursor: not-allowed;

  pointer-events: none;

  color: grey;

  background-color: white;

}


#firstCheckbox:checked+#secondCheckbox:checked+button {

  color: black;

  cursor: pointer;

  pointer-events: auto;

}

<input type="checkbox" id="firstCheckbox">

<input type="checkbox" id="secondCheckbox">

<button>Click me</button>


查看完整回答
反對(duì) 回復(fù) 2023-02-24
  • 2 回答
  • 0 關(guān)注
  • 183 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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