我試圖用jQuery做的是讓我可以在同一組中使用三個單選按鈕。當選擇其中一個時,另外兩個不應該被激活。我希望能夠使用jQuery在最終結果中顯示單獨的HTML塊,但是我無法得到一些簡單的東西來運行我正在處理的內容。jQuery單選按鈕來顯示不同的東西依賴
這裏是我目前所面對的一起工作的代碼:
$(document.ready(function()
{
$("input[name='rdiobut']").change(function(){
if ($("input['rdiobut']:checked".val() == 'a'))
$("#rdiocont").text("There is no expiration date.");
else if ($("input[name='rdiobut']:checked".val() == 'b'))
$("#rdiocont").text("Tell me how many days until expire");
else ($("input[name='rdiobut']:checked".val() == 'c'))
$("#rdiocont").text("Pick the date to expire from a calendar");
});
});
這裏是jQuery的那張表:
<tr><td>Expire Settings:</td><td>Does Not Expire: <input type="radio" name="rdiobut" value="a" checked="check" /> <strong>OR</strong> Expires By Days <input type="radio" name="rdiobut" value="b" /> <strong>OR</strong> Select a Date to Expire On <input type="radio" name="rdiobut" value="c" /></td></tr><tr id="rdiocont"><td>No Expiration Date</td></tr><tr id="rdiocont"><td>Expires by Days</td></tr><tr id="rdiocont"><td>Choose Expiration by Calendar</td></tr>
沒有人有任何建議或想法上我可能做錯了什麼?
謝謝。該腳本完全符合我的要求。我一直在遍地搜尋,以確定我是如何設置錯誤的。我非常感謝你的幫助。 – Ryan