On 21/02/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > Following up from a question I asked yesterday, I wanted to get the closest > parent DIV given an arbitrary nested element. But when I request the ".id" > of that element, i repeatedly get an "undefined" message, even though this > call, "$(this).parent("div.sidebarToDo")" yields an object. > > $('#todoList a.deleteTDItem').each(function(index) { > var divId = $(this).parent("div.sidebarToDo").id; > alert(divId); // alwasy gives 'undefined' > $(this).click = function() { $('#' + divId).remove(); > }; > }); > > This is the HTML in question: > > <div class="sidebarToDo" width="100%" id="dToDo3"> > <table cellpadding="0" cellspacing="0" border="0" width="100%"> > <tr> > <td><input id="cbTdId3" onClick="var textDecor = (this.checked ? > 'line-through' : 'none'); $('#textId3').css('text-decoration', textDecor);" > type="checkbox" id="tdcb3" ></td> > > <td id="textId3" class="sidebarText" style="text-decoration: > none">Start Work</td> > <td align="right"><a class="editTDItem" href='#'><img > src="images/edit.gif" alt="Edit" border="0"></a></td> > <td align="right"><a class="deleteTDItem" > href="javascript:toggleDiv('dToDo3');"><img src="images/deleteLink.gif" > alt="Delete" border="0"></a></td> > </tr> > </table> > </div> > > Thanks, - Dave
You can get the id via attr: $(this).parent("div.sidebarToDo").attr("id") _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/