myparentID = $(this).parent().parent().parent().attr("id");
parentID = "My table ID is: " + myparentID;
alert (parentID);
};
$("td").bind("click", getParent);
Hope that helps,
Manowar721
On Jan 31, 3:01 pm, Chrille <christoffer...@gmail.com> wrote:
> Hi everyone,
>
> I have a lot of tables, like this:
>
> <table id="stuff1"><tr><td>lorem</td><td>ipsum</td></table>
> <table id="stuff2"><tr><td>lorem2</td><td>ipsum2</td></table>
>
> I want to loop through all td:s and select the id of the parent table.
> What is the best solution for that?
>
> $('table td').each(function(){
> // select the parent table id here
> $('parenttable').attr("id");
>
> });
>
> Best regards,
> Christoffer
No comments:
Post a Comment