const elements = document.querySelectorAll( '.my-class, .your-class' ); elements.forEach(element => { console.log(element); });