<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
</head>
<body>
<div id="check">
<input type="checkbox" value="1" />1
<input type="checkbox" value="2" />2
<input type="checkbox" value="3" />3
</div>
<script type="text/javascript">
var inputs = document.querySelectorAll("#check input")
inputs.forEach(function (checkbox) {
checkbox.onclick = setMapFeatures
})
function setMapFeatures() {
features = []
var inputs1 = document.querySelectorAll('#check input')
inputs1.forEach(function(input) {
if (input.checked) {
features.push(input.value)
}
})
console.log(features);
}
</script>
</body>
</html>
JS复选框:获取选中的checkobx
最新推荐文章于 2023-11-29 08:47:53 发布