我討厭當我花這麼多時間在這樣的基本問題上,看起來很容易在我的腦海中,但只是不工作。爲什麼我的單選按鈕檢測不到檢查?
我有一個頁面有兩個單選按鈕,關於哪一個我點擊它應該把我發送到相關頁面。
的DOM:
<form id="question-form4" class="list">
<ion-radio id="question-checkbox1">YES</ion-radio>
<ion-radio id="question-checkbox2">NO</ion-radio>
</form>
<button ng-click="next()" type="submit" class="button button-assertive button-block">NEXT</button>
控制器:
$scope.next = function(){
if(document.getElementById('question-checkbox1').checked = true) {
//Male radio button is checked
$state.go('photo');
}else if(document.getElementById('question-checkbox2').checked = true) {
//Female radio button is checked
$state.go('prescription');
}
}
和當然,無論我選擇,它總是給我的頁面 「照片」。我可能做錯了什麼?
它是'='vs'=='的問題? –
'document.getElementById('question-checkbox1')。checked = true'將每個時間評估爲true。 (因爲@ÁlvaroGonzález說的) – tymeJV
你好,它不會觸發任何事情這樣做。 – FrenchyNYC