試過把'#id'變成字串組起來但還是沒辦法
function inordering(){
var lod=[];
var checkboxes = document.querySelectorAll('input[type=checkbox]:checked');
for (var i = 0; i < checkboxes.length; i++) {
gg=checkboxes[i].id
console.log() //$('#id')
}
}
document.querySelectorAll('input[type="checkbox"]:checked');
顯示被選取的checkbox的id
<html>
<body>
<input type="checkbox" class="myCheckbox" id="myCheck1">
<input type="checkbox" class="myCheckbox" id="myCheck2">
<input type="checkbox" class="myCheckbox" id="myCheck3">
<input type="checkbox" class="myCheckbox" id="myCheck4">
<input type="checkbox" class="myCheckbox" id="myCheck5">
<button onclick="showCheckedID()">show Checked Checkbox ID</button>
<script>
var array = []
var myCheckbox = document.querySelectorAll(".myCheckbox")
function showCheckedID() {
array=[]
for (var i = 0; i < myCheckbox.length; i++) {
if(myCheckbox[i].checked){
array.push(myCheckbox[i].getAttribute('id'))
}
}
console.log(array)
}
</script>
</body>
</html>