Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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/8/svg/2.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
如何使用jquery从强元素获取文本?_Jquery - Fatal编程技术网

如何使用jquery从强元素获取文本?

如何使用jquery从强元素获取文本?,jquery,Jquery,我有以下元素,需要获取选中输入复选框的强元素的文本值 <input class="inputCheckbox" tpye="checkbox"><strong>Testing</strong> 你把单词类型拼错了 <input class="inputCheckbox" type="checkbox"><strong>Testing</strong> 你把单词类型拼错了 <input class="inputChe

我有以下元素,需要获取选中输入复选框的强元素的文本值

<input class="inputCheckbox" tpye="checkbox"><strong>Testing</strong>

你把单词类型拼错了

<input class="inputCheckbox" type="checkbox"><strong>Testing</strong>

你把单词类型拼错了

<input class="inputCheckbox" type="checkbox"><strong>Testing</strong>

问题是
strong
元素不在
input
元素的内部,而是在它旁边。你有几个选择。最简单的方法是为
strong
元素指定一个类名或id。另一种方法是使用undefined建议的同级。

问题是
strong
元素不在
input
元素内,而是在它旁边。你有几个选择。最简单的方法是给
strong
元素一个类名或id。另一种方法是使用undefined建议的同级元素。

查找类似这样的
strong
元素

<p>Hello How are you <strong>Chandan </strong></p>
输出:

钱丹


要找到这样的
strong
元素

<p>Hello How are you <strong>Chandan </strong></p>
输出:

钱丹


简单键入,标记为关闭简单键入,标记为关闭
$(this).find("strong").text();