my question why when I write ClassName[1] give me undefined ? my code:
<select id="ClassNameEdit" class=" form-control" data-bind="foreach:ClassData">
<option data-bind="text:ClassName,value:ClassId, name:ClassId"></option>
</select>
<script>
let a= document.getElementById('ClassNameEdit').children
console.log(a.item(1))
</script>
To get that element with plain Javascript you would have to do:
let a = document.getElementById('ClassNameEdit').children;
console.log("my element = ", a.item(0));
The first element, would start with the index of 0 not 1.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.