2011-07-26 55 views

回答

1

你可以試試這個

if($("containerOfRadioButtons").find("input:radio:checked").length) 
{ 
    alert("Error message"); 
} 
0

如果你想在Javascript中獲得單選按鈕的價值,循環它們是最直接的解決方案。你可以指定其中一個默認選中,並確保至少選擇默認值,因爲你不能手動取消選擇一個單選按鈕(通過控制檯,是的,但這是一個完全不同的故事)

0

可以匹配與:radio:checked選擇所有選中的單選按鈕:

if (!$("input:radio:checked").length) { 
    alert("None of the radio buttons are checked."); 
} 
相關問題