[英]How to get text which is between two containers?
I need to parse some text, that is in between two containers. 我需要解析一些文本,即在两个容器之间。 I cannot change the structure of the HTML, it is how it is.
我无法更改HTML的结构,事实就是如此。 Following is the markup:
以下是标记:
<span class="location" title="Donetsk, Donetskaya, Ukraine"><img data-src="/media/images/4.0/flags/ua.gif" style="opacity: 1; visibility: visible;" src="/media/images/4.0/flags/ua.gif"> Ukraine</span>
|
Rate: $35
|
IT & Programming
<div class="eol-level-small clickable" id="snap0" onmouseover="EOL.snapshot.tip('246969','10183','snap0')" onmouseout="EOL.snapshot.tipCancel()">16</div>
What i need to extract is the text: 我需要提取的是文本:
|
Rate: $35
|
IT & Programming
How can i do this with jQuery or JavaScript? 我该如何使用jQuery或JavaScript?
It looks like the nextSibling element of the element with class location
看起来像带有类
location
的元素的nextSibling元素
$('.location')[0].nextSibling.nodeValue
不要使用没有Tag的文本,使用nextSibling是不安全的,因为nextSibling与IE和Moz具有不同的兼容性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.