Get the content of siblings elements with jQuery?

Txt isn't a parent, and even then it has to be a direct parent ( parent() matches the immediate parent if it matches the selector), instead you need: $(". UiButton"). Click(function(){ var txt = $(this).

Closest("ul"). Siblings(". Txt").text(); }) The alternative is to go all the way up to content (via closest() ) to be safe then traverse down with find() : $(".

UiButton"). Click(function(){ var txt = $(this). Closest(".

Content"). Find(". Txt").text(); }).

. Txt isn't a parent, and even then it has to be a direct parent (.parent() matches the immediate parent if it matches the selector), instead you need: $(". UiButton").

Click(function(){ var txt = $(this). Closest("ul"). Siblings(".

Txt").text(); }); The alternative is to go all the way up to . Content (via .closest()) to be safe then traverse down with .find(): $(". UiButton").

Click(function(){ var txt = $(this). Closest(". Content").

Find(". Txt").text(); }).

Thanks Nick! This was really helpful! – Luciano Dec 20 '10 at 21:16 The reason I picked your second method, was that the ul was unnamed, I prefer to pick named components in case of structural change.

+1 – Orbling Dec 20 '10 at 21:17.

You need to go up to the wrapper and down, you can go to siblings, but in this case it will be harder. $(". UiButton").

Click(function(){ var txt = $(this). Closest('. Content').

Find('. Txt').text(); }.

1 Thanks! That solution worked for me. – Luciano Dec 20 '10 at 21:09 @Luciano: Quite alright.

– Orbling Dec 20 '10 at 21:17.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions