Hi, I would like to know how I can with PURO Javascript to obtain names of CSS classes and be able to show them in the console without repeating names from a list of nodes where I obtain the elements looking for the first class. Elements with class AAA always have 2 classes only: AAA and another class that varies and repeats: With this function I see the classes but repeated:
[].forEach.call(document.querySelectorAll('.AAA'), function(elem) {
console.log(elem.className);
});
<span class"AAA BBB"></span>
<span class"AAA CCC"></span>
<span class"AAA DDD"></span>
<span class"AAA EEE"></span>
<span class"AAA FFF"></span>
<span class"AAA GGG"></span>
<span class"AAA BBB"></span>
<span class"AAA CCC"></span>
<span class"AAA DDD"></span>
<span class"AAA EEE"></span>
<span class"AAA FFF"></span>
<span class"AAA GGG"></span>
I would like to be able to see all types of classes in the console after obtaining all the elements with the class "AAA", that is something like this:
BBB CCC DDD EEE FFF GGG
Neither do I care if both are shown as AAA BBB, AAA CCC, etc.
Thank you very much.