我有一個名爲「other」的單選按鈕,當選中時,我想要一個名爲「other-text」的輸入字段顯示出來。這很簡單,但我整個上午都失敗了。如何使用jquery檢查單選按鈕時顯示輸入字段
<input name="ocalls" type="radio" name="other" id="other-radio" value="Yes"><b>Other</b><br />
<input type="text" name="other-text" id="other-text" style="display:none" />
這裏是我的javascript:
失敗的jQuery(function(){
jQuery("input[name=other]").change(function(){
if ($(this).val() == "Yes") {
jQuery("#other-text").show()
}
else {
jQuery("#other-text").hide();
}
});
});
的jsfiddle。 http://jsfiddle.net/Wpt3Y/532/
http://jsfiddle.net/Wpt3Y/537/ –