how do you create a nodelist that can be loaded with a for loop instead of an array in javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

20th Nov 2017, 9:39 PM
samuel
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.
21st Feb 2021, 6:18 PM
EthanE230
EthanE230 - avatar