get all elements by class name and tag code example Example: get element by class name var y = document.getElementsByClassName('foo'); var aNode = y[0];