Domanda

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');
È stato utile?

Soluzione

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');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top