• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to find parent table from td in Jquery

 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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">
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Running your code, I get the <tbody> element, rather than undefined, but...

What you really want is:
 
Praful Thakare
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic