0

I select

$("a.tp[programm='" + programm + "']");

then I want to select its nested element span.thump and set the text of it. How do i realize that?

<h4><a programm="74" class="tp" href="#"><img src="/images/tuo.png"></a><a href="">
<img width="180" height="40" src="/images/kauf_default.png"><br>test 
<span class="thump">1</span><img src="/images/ilike.png"></a></h4>
1
  • Could you post the html too, please? Commented Sep 16, 2010 at 15:31

2 Answers 2

3

Do you mean something like

<a class="tp" programm="foo">blah <span class="thump">setTextOfThis</span> blah</a>

? If so, try

$("a.tp[programm='" + programm + "'] span.thump").text(newText);

Edit: Regarding the update, try

$("a.tp[programm='" + programm + "'] + a span.thump").text(newText);

(You may want ... ~ a span.thump if the <a> containing that <span> is not immediately next to that <a programm>.

Sign up to request clarification or add additional context in comments.

3 Comments

postet my html code above, this solution does not work I tried already
what is the + operator doing here? I couldn't find it in the documentation.
the + is just concatanating the strings to build the selector. programm is a variable.
0

Well, the <span> you are looking for is not a child of that <a> tag you are selecting, so you will need to traverse to the .parent() node and .find() the correct child.

$("a.tp[programm='" + programm + "']").parent().find('.thump');

1 Comment

why not just use siblings() ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.