I have the following array that holds a number of option elements, depending on if it has the hidden class or not.
var list = $('#condition option').not('.hidden');
How can I get an array of classes these elements have?
What I have tried:
var list = $('#condition option').not('.hidden').attr('class');
However, this only returns classes associated with the last element in the array.
$('#condition option')and loop through it like with.eachas @Huangism said?let listOfClasses = Array.from(document.querySelectorAll('#condition option')).map(el => el.getAttribute('class')).filter(cls => !cls.match(/hidden/));One liner, no jquery.