javascript - How to create a html collection of elements located in separate divs -
i need create html collection containing 5 input-elements, type = text.
the html:
<div class="outerdiv"> <label><input type="checkbox" align="middle"> <img src="lorem.jpg" alt="img 1" class="image"> </label> <div class="innerdiv"> <label>lorem<input type="text" value="lorem"></label> </div> </div>
when this, collection input-elements, want ones has value = text.
innerdivtag = document.getelementsbytagname("input");
and when this, 5 separate collections , not aim.
for (i = 0; < outerdiv.length; i++) { innerdivtag = innerbox[i].getelementsbytagname("input"); }
you can use queryselectorall
document.queryselectorall("input[type='text']");
Comments
Post a Comment