I want to run a function that removes a number of divs when a check box is unchecked. The divs contain a class that has to match with the check boxes class for it to be removed.
The variable matchedDots is getting the divs that match the variable class of checkBoxID.
checkBoxID is the class of the check box being unchecked.
var checkBoxID = $(this).attr('class');
var matchedDots = $('.current-map').find('div').hasClass(checkBoxID);
if (!$(this).is(':checked'))
{
//do something
};
So really what im trying to do is say “IF the check box is unchecked AND the div class matches up with the checkbox’s class, do something.
I don’t need the info of how to remove the divs, just how to select them, as currently all I’m selecting is the unchecked check box.
Thanks guys.
Sorry if I have been confusing you guys but I have worked it out myself. Here is the code below. It was definitely easier than I thought it would be.
@Alex, thanks for your input though! really appreciated that.
Basically I am getting the
classfrom the check box. Then running anIFstatement to see if the check box has been unchecked, if it has, I remove thedivs with the same class as the check box.