aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to find parent table from td in Jquery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to find parent table from td in Jquery" Watch "How to find parent table from td in Jquery" New topic
Author

How to find parent table from td in Jquery

Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Hi, I have following dom. and I have to select the table using class row1 for td.

if i write var row1 = $("td.row1").parent();alert($(row1).attr("class")); it prints zakas but if give

var row1 = $("td.row1").parent();
row1=$(row1[0]).parent(); then alert gives me undefine.

any help?



<table cellpadding="0" cellspacing="0" class="zakas1" border="0" width="100%">
<tr class="zakas">
<td class="row1">


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

Running your code, I get the <tbody> element, rather than undefined, but...

What you really want is:


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 641
Thanks much Bear, I understand what this means, but unable to get why parent.parent does not work? is there any limit for using parent.parent.parent... ?

well I am just at chapter 2 of your book, so not fully armed, i guess i will be in better position after few weeks.

can you also help me with following code ( i know spoon feeding is not good, but its really late here and im scratching my head for long ), from following code i have to get all <a tags and assign some id and class to them so that they look like <a href="" id="sort_col1" class="sorted_by_descending">some text </a>.


[ April 28, 2008: Message edited by: Praful Thakare ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find parent table from td in Jquery