I am trying to find the exact value of a class name containing the text iconGroup and I am able to get an array of class names using:
var chosenIconClassArray = $('.selectedGroupIcon').attr('class').split(/\s+/);
console.log(chosenIconClassArray);
$.each(chosenIconClassArray, function(index, item) {
console.log(item);
});
This gives a console output of:
["createAGroupIconList", "inlinelist", "ram", "left", "iconGroup20", "selectedGroupIcon"]
createAGroupIconList
inlinelist
ram
left
iconGroup20
selectedGroupIcon
I have tried something along the lines of this to find which iconGroup it is, but it didn't work:
if (item ^= 'iconGroup') {
console.log($(this));
}
The goal is to be able to tell that the class array contains the value iconGroup20 (or any number such as 1, 2, 3, 4, etc) which I can then add to another element to update it's icon.
How can I go about searching that array and then find which iconGroup class is in it?