单个radio的选中与取消

js单个选项的选中与取消

当页面只有一个radio时,选中后发现无法取消,需要手动添加事件控制。

<div class="form-group col-md-4">
	<label>查询条件</label><br>
<input id="isByConsoliId" value="1" name="selectType"  type="radio" onclick="changeStatus()"/><label>按寄托号查询</label>
	</div>

//当个选择的选中与取消
function changeStatus(){
	if ($('#isByConsoliId').attr('checked')) {
		 $("#isByConsoliId").attr('checked', false); 
	}
	 else {
		 $("#isByConsoliId").attr('checked', 'checked'); 
	 }
} 

猜你喜欢

转载自blog.csdn.net/RUIMENG061511332/article/details/83656738