Javascript: Traversing through array and accessing its various elements? -


essentially i'm trying right is, given input text, split white space , display on

div id= "animation" 

every time button clicked, array should go forward 1 word.

this current attempt.

function displaytext() {     var displaytext = document.getelementbyid("animation");     var list = (document.getelementbyid("input").split(/[ \tn]+/);     (var = 0; < list.length; i++) {         displaytext.innerhtml = list.get[i];     } } 

is thought process correct? whatever reason, doesn't seem working.

there multiple issues in method

function displaytext() {     var displaytextanimation = document.getelementbyid("animation"); //keep variable name , method name different     var list = (document.getelementbyid("input").value).split(/[ \tn]+/); //use value property , observe bracket     (var = 0; < list.length; i++) {         displaytextanimation.innerhtml = list.charat(i); //observe replacing charat     } } 

Comments