I’m currently using jQuery and would like some help on iterating through all “checked” checkboxes and remove a class (called “new_message”) of the parent table row.
I’ve got a basic concept, but I can’t quite figure the entire thing out.
Here is what I am currently using:
$("#unread_button").click(function (event) {
event.preventDefault;
$(":checkbox:checked").each(
function()
{
if (this.checked)
{
var divs = $.makeArray($(this).parents("tr").attr("id"));
}
$(divs).each(
function(int)
{
$(this).removeClass("new_message");
}
);
});
});
Eventually, this will be updating a database as well, so if the code can be tailored to accomodate both, that’d be great.
Any guidance is much appreciated!
I think this will work:
Or if it’s only the direct TR parent you want to match, then this:
jQuery does all the looping for you so you should have to have all the each()es.
Once you use the ‘:checked’ selector, you should have to recheck if the item is checked. This should limit your selector results to only checked items.