I have a small form in javascript with two Input values with the same class name. I know that you can target them by giving them ids but is there a way to target them using array values?
<td>
<input class="inputtextb" type="text" name="adults" maxlength="3"> Adults
<input class="inputtextb" type="text" name="children" maxlength="3"> Children above 5 years
You can use
document.getElementsByClassName()for that:In case that doesn’t work – can i use getElementsByClassName – you could iterate over all
<input>elements usingdocument.getElementsByName()and filter out the ones you want; or use jQuery 😉