Search code examples
javascriptcssdomelementmozilla

Why getElementsByClassName do not work in Mozilla?


I am trying to get an element of a webpage by using getElementsByClassName. I typed in firebug console

getElementsByClassName('classname');

and it returns with

ReferenceError: getElementsByClassName is not defined

I read in this page that firefox supports getElementsByClassName. I have updated firefox. Why I am getting this error?


Solution

  • You need to use the correct format. It is a method of the document object.

    document.getElementsByClassName('classname');