This is my html code:
<div class="input_cont">
<Input type="hidden" id="time" name="time">
</div>
<div class="input_cont">
<Input type="hidden" id="time" name="time">
</div>
<div class="input_cont">
<Input type="hidden" id="time" name="time">
</div>
And this is my javascript code:
const getTime = () {
const inpCont = document.querySelectorAll('.input_cont #time');
inpCont.forEach((fields) => {
fields.querySelector('#time').value = '5:00:00 AM';
});
}
getTime();
But I am getting these errors:
- Uncaught TypeError: cannot set property 'value' of null.
- At NodeList that forEach ()
- At getTime
- Uncaught TypeError: cannot set property 'value' of null.
Please help me, I am still learning and this is for my school project. Thank you.