0
how do you create a nodelist that can be loaded with a for loop instead of an array in javascript
I am creatinf an input element each time a button is clicked. The user enters info into the text areas and when I click a second button it needs to display the info. Entered by the user and display it + .sort it alphabetically? Any help would be great feel free toemail me torresemator158@gmail
1 Answer
0
For the button you could add a function so everytime it I'd clicked it creates an input element at I assume a div,
var input = placeHolderDiv.createElement("input")
input.classList.add("myInput");
For the second button it could have an onclick function that does
var arr = [ ];
for(b of document.getElementsByClassName("myInput")) {
arr.push(b.value);
}
arr.sort();
Display the array anywhere on the page and it should work.