Ben Shelock
Ben Shelock

Reputation: 20965

Bug or My Stupidity

Not sure if I've just missed something but this doesn't work:

$(this).children('td.threadtitle a').html('thread title');

However this does

$(this).children('td.threadtitle').children('a').html('thread title');

I'm just trying to understand why this is occuring. But is this a bug?

Upvotes: 1

Views: 118

Answers (2)

hobbs
hobbs

Reputation: 239950

The selector argument to .children is a filter. $(this).children('td.threadtitle a') finds nodes which match the selector td.threadtitle a and are direct children of this. Assuming that your threadtitle tds are inside of this, and not above or equal to it, this situation will never happen.

I think that what you might really be looking for is a contextualized selector:

$('td.threadtitle a', this).html("Thread title")

which finds things that match that selector as long as they occur anywhere under this.

Upvotes: 2

Kobi
Kobi

Reputation: 138017

  1. Should work. Can you upload some code so we can see your html?
  2. Just a note: If you want children, you should use "td.threadtitle > a". Otherwhise it should be find('a').

Upvotes: 0

Related Questions