I can\'t figure out why this isn\'t working:
$(document).ready(function() {
if ($(\'.checkarea.unchecked\').length) {
$(this).parent().parent().pa
wow, you can use closest or parents() method.
closest( selector )
Get the first element that matches the selector, beginning at the current element and progressing up through the DOM tree.
parents( [selector] )
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
I'd suggest:
$('.toggle-open-area').click(function() {
$(this).toggleClass('unchecked checked');
$(this).closest(appropriateSelector).toggleClass('open closed');
});
Incidentally, I can't provide an actual selector in place of appropriateSelector
because your posted image1 doesn't (seem to) include that particular element.
References:
1. You realise you could include the actual mark-up in the question? It's much more convenient that way, and far easier to work with (create demos from, correct typos, retain usefulness in the event the external site falls over, dies or reorganises its content...).