本文實例講述了jquery獲取radio值的方法,分享給大家供大家參考。具體如下:
單選組radio:
單選組 radio:
獲取一組radio被選中項的值
radio單選組的第二個元素為當前選中值
jquery老的版本
獲取radio值的jquery實例:
			var_name = $("input[name='isspecialcnt']:checked").val();
			//alert(var_name);
			if(var_name=='1'){
			$("#isspecialcntyes").show();
			$("#isspecialcntno").hide();
			}
			if(var_name=='0'){
			$("#isspecialcntyes").hide();
			$("#isspecialcntno").show();
			}
			}
			<form name="form1" method="post" action="">
			<p>
			<label>
			<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_0">
			單選</label>
			<br>
			<label>
			<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_1">
			單選</label>
			<br>
			<label>
			<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_2">
			單選</label>
			<br>
			<label>
			<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_3">
			單選</label>
			<br>
			<label>
			<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_4">
			單選</label>
			<br>
			<label>
			<input type="radio" name="radiogroup1" value="單選" id="radiogroup1_5">
			單選</label>
			<br>
			</p>
			</form>
希望本文所述對大家的javascript程序設計有所幫助。
新聞熱點
疑難解答
圖片精選