Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery,选择嵌套元素_Javascript_Jquery_Jquery Selectors - Fatal编程技术网

Javascript jQuery,选择嵌套元素

Javascript jQuery,选择嵌套元素,javascript,jquery,jquery-selectors,Javascript,Jquery,Jquery Selectors,我选择 $("a.tp[programm='" + programm + "']"); 然后我想选择它的嵌套元素span.thump并设置它的文本。我是如何认识到这一点的 <h4><a programm="74" class="tp" href="#"><img src="/images/tuo.png"></a><a href=""> <img width="180" height="40" src="/images/kauf

我选择

$("a.tp[programm='" + programm + "']");
然后我想选择它的嵌套元素span.thump并设置它的文本。我是如何认识到这一点的

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

你是说

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

编辑:关于更新,请重试

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

(如果包含该
不是紧挨着该

,您可能需要一个span.thump,您的意思是

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

编辑:关于更新,请重试

$("a.tp[programm='" + programm + "'] + a span.thump").text(newText);
(如果包含该
不是紧挨着该

,您可能需要一个span.thump,那么,您要查找的
不是该
节点的子节点和正确的子节点

$("a.tp[programm='" + programm + "']").parent().find('.thump');
嗯,您要查找的
不是该
节点的子节点,而是正确的子节点

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

请你也发布html好吗?请你也发布html好吗?请在上面发布我的html代码,这个解决方案不起作用。我已经尝试过了。
+
操作符在这里做什么?我在文档中找不到它。+只是浓缩字符串来构建选择器。programm是一个变量。在上面发布我的html代码,这是解决方案不起作用我已经试过了,
+
操作符在这里做什么?我在文档中找不到它。该+只是连接字符串以构建选择器。programm是一个变量。为什么不直接使用
同级()
?为什么不直接使用
同级()