Hide element by class in pure Javascript

document.getElementsByClassName returns an HTMLCollection(an array-like object) of all elements matching the class name. The style property is defined for Element not for HTMLCollection. You should access the first element using the bracket(subscript) notation. Updated jsFiddle To change the style rules of all elements matching the class, using the Selectors API: If for…of is available: