0
我正在嘗試監視收音機組上的更改。單選按鈕檢查屬性不更新用戶操作
我使用面漆,具有以下HTML:
<ul class="topcoat-list">
<li class="topcoat-list__item">
<label class="topcoat-radio-button__label">
<input type="radio" name="topcoat" value="1" checked="checked">
<div class="topcoat-radio-button"></div>
Test1
</label>
</li>
<li class="topcoat-list__item">
<label class="topcoat-radio-button__label">
<input type="radio" name="topcoat" value="2">
<div class="topcoat-radio-button"></div>
Test2
</label>
</li>
<li class="topcoat-list__item">
<label class="topcoat-radio-button__label">
<input type="radio" name="topcoat" value="3">
<div class="topcoat-radio-button"></div>
Test3
</label>
</li>
</ul>
對於原因,我不完全得到的checked
屬性的時候使用選擇另一個單選按鈕沒有更新......
我想能夠監測與JavaScript的變化,但現在,我不能得到無線電集團的價值...
$('input[name=topcoat]').change(function(){ changed() });
function changed() {
id = $('input[name=topcoat]').val();
alert(id);
}
當你選中一個複選框,它是被更新不是屬性 –
你可以使用'$(輸入所選擇的項目'[NAME =‘面漆’]屬性:checked')。val()' –
@ArunPJohny,你的評論解決了我的問題。我將答案標記爲已接受(我不知道你們中的哪一位是第一位)。 –