Javascript Get All Class element and convert it into array

var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));

Explanation:
document.querySelectorAll(‘ClassName ID’) – Get All Class or id element and put into object
Array.prototype.slice.call – Convert Object into Array

Looping:-

elems.forEach(function(html) {
    ### Your Code Here ###
});

You may also like...