79419567

Date: 2025-02-06 23:07:10
Score: 1
Natty:
Report link

The selected answer from @sdepold stated in 2012:

Sadly there is no forEach method on NodeList

The forEach method has since become part of the NodeList-Prototype and is widely supported (10 out of Top10 browsers /mobile/desktop)

https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#browser_compatibility

I thought this question could benefit from a little update.

var nodes = document.getElementsByClassName('warningmessage')

Or more modern (and better):

const nodes = document.querySelectorAll(".warningmessage")

nodes.forEach( element => {
    element.remove()
}) 
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @sdepold
  • Low reputation (0.5):
Posted by: IoT-Practitioner