我有多個單選按鈕。在我有的代碼中,它們是與不同功能對應的不同圖片。單擊標籤的單選按鈕
用戶必須知道哪個單選按鈕被點擊。因此,我試圖找到一種方法來改變單擊按鈕後單選按鈕的背景。 爲了使代碼正常工作,<label>
必須圍繞<input>
標籤。
<div class="radio-toolbar">
<label class="BottomLeft">
<input id="tech" type="radio" ng-model="SelectedLayout" value="BottomLeft" />
</label>
<label class="BottomRight">
<input id="tech" type="radio" ng-model="SelectedLayout" value="BottomRight" />
</label>
<label class="Dual">
<input id="tech" type="radio" ng-model="SelectedLayout" value="Dual" />
</label>
<label class="DualRight">
<input id="tech" type="radio" ng-model="SelectedLayout" value="DualRight" />
</label>
<label class="Duplex">
<input id="tech" type="radio" ng-model="SelectedLayout" value="Duplex" />
</label>
<label class="Custom">
<input id="tech" type="radio" ng-model="SelectedLayout" value="Custom" />
</label>
</div>
這裏的JSfiddle
? 「id」的重點在於它允許你通過它的'id'來查找元素。但是,只有當你的'id's是唯一的。 –
ID應該始終是唯一的 – guradio
我有一段代碼,我通過ID獲取元素。由於他們都必須相互對應,所以我使用了相同的ID。這不是完美的方式,但我使用必要的代碼'initDropDown(document.getElementById('tech'));' – MarLen