<div class="input-group">
<input type="password" maxlength="1" value="" readonly="">
<input type="password" maxlength="1" value="" readonly="">
<input type="password" maxlength="1" value="" readonly="">
<input type="password" maxlength="1" value="" readonly="">
</div>
document.querySelector('input[value=""]').value = 1
This works:
document.getElementById('fill').addEventListener('click', evt => {
document.querySelector('input[value=""]').setAttribute('value', '1');
});
<div class="input-group">
<input type="password" maxlength="1" value="" readonly="">
<input type="password" maxlength="1" value="" readonly="">
<input type="password" maxlength="1" value="" readonly="">
<input type="password" maxlength="1" value="" readonly="">
</div>
<button id="fill">Fill</button>
.value = ...
is not actually changing the attribute itself in the DOM. Use .setAttribute
to make the actual change in the DOM that querySelector
can see.