Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

  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').
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top