vendredi 19 août 2016

get element id from array javascript

I have an array which is just id for buttons on mysite. I stead of getting the button id individually, ive put them in an array because I feel it'ld save me a lot of time.

var array = ['home', 'about', 'contact'];
for(i=0; i < array.length; i++){
    var Button = document.getElementById(array[i]);
}

My question is how do I get individual button names I can use as reference.

Button.innerhtml just lists all contents of all 3 in d array instead of individually

Aucun commentaire:

Enregistrer un commentaire