I got a div in Javascript, which has two classes one for category(specific for each) and one for CSS styling. I got that div correct div in .closest method but I want to fetch its category class which is any one of these:
Nature or Trivia or Sports or Food.
HTML:
Nature
Test your wildlife knowledge about our amazing green planet.
Trivia
Guess random quiz facts and challenge your brain with tests.
Food
Guess global dishes and test your taste buds with good food.
Sports
Guess athletic leagues and test your scores in game matches.
Javascript:
const selectedCategoryDiv = selectedCategory.closest('.sports, .trivia, .nature, .food');
const category = selectedCategoryDiv.classList.filter(cls => cls !== '.category-cards');
console.log(category);