ラジオの情報を取得するチェックボックスを選択します

彼らは、レコードので、忘れがちなので

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form id="box">
		<input type="checkbox" name="box" value="哈哈">哈哈
		<input type="checkbox" name="box" value="嘿嘿">嘿嘿
		<input type="checkbox" name="box" value="呵呵"> 呵呵
		<input type="checkbox" name="box" value="憨憨">憨憨
		<input type="radio" name="radio" value="嗯嗯">嗯嗯
		<input type="radio" name="radio" value="哦哦">哦哦
		<input type="button"  value="提交" onclick="go()">
	</form>
</body>
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
	// 获取checkbox和radio中的被选中的value
	function go(){
		var select = [];
		$("#box input[type='checkbox']:checked").each(function(index,item){
			select[select.length] = item.value;
		})
		console.log("checkbox:"+select);
		
		
		var radio = $("#box input[type='radio']:checked").val();
		console.log("radio:"+radio);
	}
</script>
</html>
リリース6元記事 ウォンの賞賛2 ビュー149

おすすめ

転載: blog.csdn.net/qq_42950149/article/details/105081527