MY html has multiple divs that share the same class name and they have input elements with unique ids, I want to append a span under all of these inputs with JavaScript without editing the html.
this is the part of html
<form name="form" onsubmit="return validate();" method="get">
<div class="form-group">
<label for="pass">Password</label>
<input type="password" class="form-control" name="pass" id="pass">
</div>
<div class="form-group">
<label for="pass2">Re-Type Password</label>
<input type="password" class="form-control" name="pass2" id="pass2">
</div>
.
.
.
</form>
this my JS to create and append the span
const errorMessage = document.createElement('span');
errorMessage.textContent = "invalid input";
document.querySelector('.form-group').appendChild(errorMessage);
But this only creates one span in the first div