-feira, 3 de junho de 2009 15:15
Assunto: [jQuery] Re: text of first sibling of a parent...How do I get
it
There is no reason why you shouldn't get this working with one of the
examples provided. For the nesting issue, filter with :first:
$('#knowndiv').parents('tr:first').children
Mauricio, your code basically works fine on a simple test page. But
there is something about my set-up that makes the bit about
.parents('table') fail. My page still has the same exact element
structure with 2 differences; there are 52 trs in the table; also,
all the elements (tables, trs, tds,
have you tried
var myText = $('#knowndiv').parents('tr').find('td:first').text();
alert(myText);
The TR is really the parent of the TDs, not the table.
On Jun 3, 7:33 am, jake dimano jakedim...@gmail.com wrote:
Mauricio, your code basically works fine on a simple test page. But
there is
The problem with parents() in the example given is that if your page
structure is more complex, and has nested tables for example, then
parents() will return all parent tables. Likewise if there are tr's
preceding the tr in your example. Here's a couple ways to get the text
you're asking for:
Yes, that is the first thing I did, to no avail. I think all I am
left with just trudging through this with pure javascript.
jake
On Wed, Jun 3, 2009 at 11:20 AM, BigAB adamlbarr...@gmail.com wrote:
have you tried
var myText = $('#knowndiv').parents('tr').find('td:first').text();
I must say, I have not tried closest() and prevAll(). I'll give
it another go with your suggestions before I throw in the towel.
Thanks.
jake
On Wed, Jun 3, 2009 at 11:22 AM, mkmanning michaell...@gmail.com wrote:
The problem with parents() in the example given is that if your page
There is no reason why you shouldn't get this working with one of the
examples provided. For the nesting issue, filter with :first:
$('#knowndiv').parents('tr:first').children('td:first').text();
parents(xx:first) is similar to closest(xx), only the latter will also
try to match the element
ensure that the script src of jquery is correct
On Wed, Jun 3, 2009 at 8:15 PM, Ricardo ricardob...@gmail.com wrote:
There is no reason why you shouldn't get this working with one of the
examples provided. For the nesting issue, filter with :first:
: [jQuery] Re: text of first sibling of a parent...How do I get it
There is no reason why you shouldn't get this working with one of the
examples provided. For the nesting issue, filter with :first:
$('#knowndiv').parents('tr:first').children('td:first').text();
parents(xx:first
: http://docs.jquery.com/Traversing
Maurício
-
-Mensagem Original-
De: Ricardo
Para: jQuery (English)
Enviada em: quarta-feira, 3 de junho de 2009 15:15
Assunto: [jQuery] Re: text of first sibling of a parent...How do I
-
De: Ricardo
Para: jQuery (English)
Enviada em: quarta-feira, 3 de junho de 2009 15:15
Assunto: [jQuery] Re: text of first sibling of a parent...How do I get it
There is no reason why you shouldn't get this working with one of the
examples provided. For the nesting issue, filter
first lets give an ID to your table
table id=mytable
now heres your script.
var obj = $(mytable);
var rows = $(tr):
// according to this we going to find text in the first td of the first tr
rows.each(function(i) {
var columns = rows.eq(i);
alert(columns.eq(0).text());
});
the script
12 matches
Mail list logo