0

I am trying to travers up the tree and then down again but I do not seem to be able to combine the parent method and a regular selector.

here is what I am trying, I need to get the parent to establish the element that is being clicked and then traverse down again to the selector (#info div.tab)

$( $(this).parent() > '#info div.tab').addClass('hide-tab');
Dennis
  • 32,200
  • 11
  • 64
  • 79
LeBlaireau
  • 17,133
  • 33
  • 112
  • 192
  • You should show us your relevant html code as i suspect it is not valid – A. Wolff Jun 10 '13 at 11:12
  • The `>` only gets used as a selector when it is inside a string. In your code, it is being interpreted as the "greater than" operator and converting `$(this).parent()` to a string to do a comparison. Your code evaluates to `$(true).addClass('hide-tab');` – Dennis Jun 10 '13 at 11:18

1 Answers1

2

I think you want:

$(this).parent().children('#info div.tab').addClass('hide-tab');

But as IDs must be unique on context page, should be:

$('#info div.tab').addClass('hide-tab');
A. Wolff
  • 74,033
  • 9
  • 94
  • 155