How can I get HTML elements by class in JavaScript?

后端 未结 5 1476
渐次进展
渐次进展 2021-01-22 03:15

I\'m trying to manipulate the HTML through getElementsByClass() but for some reason it doesn\'t work. When I use document.getElementByID() it works? Wh

5条回答
  •  情书的邮戳
    2021-01-22 03:45

    getElementsByClassName returns a NodeList. you will have to use

    document.getElementsByClassName('boldStuff')[0].innerHTML

    refer the docs at mdn

提交回复
热议问题