Instead of using document.getElementById()
you can now use document.querySelector()
for different cases
more info from another StackOverflow answer:
querySelector
lets you find elements with rules that can't be expressed withgetElementById
andgetElementsByClassName
EXAMPLE:
document.querySelector('input[name="myInput"]').value = 'Whatever you want!';
or
let myInput = document.querySelector('input[name="myInput"]');
myInput.value = 'Whatever you want!';
Test:
document.querySelector('input[name="myInput"]').value = 'Whatever you want!';
_x000D_
<input type="text" name="myInput" id="myInput" placeholder="Your text">
_x000D_