Как исправить Cannot read properties of null (reading 'value') ?
HTML:
<body>
<video autoplay loop muted class="videoBG" src="img/matrixBG.mp4"></video>
<div class="container">
<div class="main-block">
<img class="logo" src="img/logo.png" alt="">
<span class="sublogo">
matrix determinant calculator
</span>
<span class="sublogo mtNone">
press '=' to count determinant
</span>
<div class="main-block-flexbox">
<div class="main-block-flexbox__matrix-flexbox">
<span></span>
<div class="main-block-flexbox__matrix">
<form action="#">
<input id="m1Value" type="number" value="0">
<input id="m2Value" type="number" value="0">
<input id="m3Value" type="number" value="0">
<input id="m4Value" type="number" value="0">
<input id="m5Value" type="number" value="0">
<input id="m6Value" type="number" value="0">
<input id="m7Value" type="number" value="0">
<input id="m8Value" type="number" value="0">
<input id="m9Value" type="number" value="0">
</form>
</div>
<span></span>
</div>
<div class="output">
<button class="equal" id="equal">
=
</button>
<input type="number" value="0">
<button class="arrDownBtn">
<img src="img/arrowDown.png" alt="">
</button>
</div>
</div>
</div>
</div>
<script src="js/main.js"></script>
</body>
</html>
JS:
const equalButton = document.getElementById('equal');
function getInputRanges() {
let arrRanges = [];
let underArr = [];
for(let index = 1; index < 10; index++) {
if (index % 3 == 0) {
arrRanges.push(underArr);
underArr = [];
}
let ind = index.toString;
let val = document.getElementById('v' + ind + 'Value').value;
underArr.push(val);
}
console.log(getInputRanges())
return arrRanges;
}
equalButton.onclick(getInputRanges());
Ошибка:
Uncaught TypeError: Cannot read properties of null (reading 'value')
at getInputRanges (main.js:13:63)
at main.js:19:21