Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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/9/loops/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,鉴于此html: <div id='tst1'> <div id='tst2'>tst2</div> <div id='tst3'>tst3</div> this is the text i want </div> 如何选择“这是我想要的文本”文本?$”文本提供tst1中包含的所有文本元素,例如tst2、tst3等 我不能依赖于知道上面包含的包装元素tst2、tst3的id,但我可以依赖于我希望在组中最后列出的

鉴于此html:

<div id='tst1'>
  <div id='tst2'>tst2</div>
  <div id='tst3'>tst3</div>
  this is the text i want
</div>
如何选择“这是我想要的文本”文本?$”文本提供tst1中包含的所有文本元素,例如tst2、tst3等

我不能依赖于知道上面包含的包装元素tst2、tst3的id,但我可以依赖于我希望在组中最后列出的文本。

尝试以下plz:

您还可以查找innerHTMl和outterHTML

试试这个plz:

您还可以查找innerHTMl和outterHTML


或者,如果Tats的建议不起作用:

var text = $('#tst1').text();
text.substr(-23);

或者,如果Tats的建议不起作用:

var text = $('#tst1').text();
text.substr(-23);

这不是substr的正确语法:应该是text.substr-23,或者为了更好的跨浏览器支持text.slice-23,但即使忽略这一点,我也不认为OP事先知道文本的长度;编辑它…是的,如果它不是为了那个特定的文本,那就真的不好了。是的,我不能指望细节…只是一般的格式这不是substr的正确语法:应该是text.substr-23,或者为了更好的跨浏览器支持text.slice-23,但即使忽略这一点,我也不认为OP事先知道文本的长度。哈哈,最近太多了;编辑它…是的,如果它不是为了那个特定的文本,它真的不好。是的,我不能指望细节…只是一般format@mix别担心!很高兴它有帮助:@Tats_innit有时:,睡眠是不确定的:P@mix别担心!很高兴有帮助:@Tats\u有时:,睡眠没有定义:P