I need to remove a class from all table cells when an element’s parent has a particular ID.
$(".closethis").click(function(){
var $this = $(this).parent().parent();
if ($this.attr("id") == "mainArea") {
$("#myTbl").removeClass("myClass");
}
});
I do need to check for ID because this is part of a function and if ID is not equal to this value it is probably for another case.
Looks right but it does not seem to work. Am I missing something?
Hmm.. Ok.. $var looks like PHP.. i’d just call it was it is. Also, you have #. in your myTbl which means id and class…. so it depends on how you are identifying the cells.. but assuming the cells are td’s inside a table ID’d “myTbl”, try this
If you can’t make that work, give us the ID’s or class’s of each element and we can give you the correct code.