var cen = document.getElementsByClassName('cen')[0] code example Example: getelementbyclass var selector = document.getElementsByClassName('class-name');