search

Home  >  Q&A  >  body text

javascript - Regarding creating arrays, will the array values ​​change the html.

Let me ask my friends in SF. In the code below, colors has three variables, which are three colors.
So, if you run it in chrome and colors[0] is 0, then run wihte, won't it change the color of the code with the id of colors in the html file?

var colors = new Array('wihte',

                    'black',
                    'custom')

var el = document.getElementById('colors');
el.textContent = colors[0];

女神的闺蜜爱上我女神的闺蜜爱上我2709 days ago778

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-07-05 11:07:53

    When you simply operate an array, you only change the values ​​in the array, which has no meaning. The real change to the html is when you operate the dom

    reply
    0
  • Cancelreply