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. 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?
It looks like the nextSibling element of the element with class location
$('.location')[0].nextSibling.nodeValue
Demo: Fiddle
不要使用没有Tag的文本,使用nextSibling是不安全的,因为nextSibling与IE和Moz具有不同的兼容性。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.