Apologies if the title is unclear, I am still learning Javascript and Jquery which sometimes makes it challenging to phrase questions correctly.
Here's the scenario:
I have numerous divs all labeled with a class of thumbnail:
<div class="thumbnail">
In addition, some of these classes may be in an expanded state at any point, like so:
<div class="thumnail expanded">
Everything functions properly and they expand as required.
I want to implement logic that triggers when a user clicks on any of these thumbnails to expand them:
$( ".thumbnail a" ).click(function() {
});
This check works well, and I can display a popup upon click that records the thumbnail anchor clicks successfully.
However, I am unsure how to identify instances of thumbnails that also have an expanded class, and then remove that class. I attempted something like this:
$( ".thumbnail .expanded").removeClass("expanded");
Inside the thumbnail click event, but it did not work. I am uncertain about what I am missing here, so any assistance would be greatly appreciated. Thank you!