开发者

jQuery, Select nested element

I select

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

then I want to select its nested element span.thump and set the text of it. 开发者_JAVA百科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>


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>.


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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜