如何抓住内容 [英] How to grab content
本文介绍了如何抓住内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的HTML节点:
I have such HTML node:
<div id='parent'>
<a href="#">test</a>
Need this
</div>
如果我处理 parent <如何获取'需要此'文本/ code>对象?
我试过类似: $('#parent')。text()
但它也返回'test'。
How to get 'Need this' text if I have handle for parent
object?
I tried something like: $('#parent').text()
but it also returns 'test'.
ps关于编辑html的 Nothing !我只是有这样的内容,我需要解析它。
p.s. Nothing about editing html! I just have such content and I need to parse it.
推荐答案
如果您知道文本内容始终是最后一个内容div,你可以这样做:
If you know that the text content is always the last content in the div, you can do:
$('#parent').contents().last().text();
此加价:
<div id='parent'>
<a href="#">test</a>
Need this
</div>
退货: 需要此
示例: http://jsfiddle.net/64RVf/
这篇关于如何抓住内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文