Skip to content Skip to sidebar Skip to footer

Jquery: Get Text Between Two
Elements

i've got a HTML tree like this:
     This is line 1
This is line 2
This is line 3
This is line 4).map(function(){ return this.previousSibling.nodeValue; }); alert(text[0]);

Demo: http://jsfiddle.net/Bg9PT/


Solution 2:

You can use previousSibling property:

document.getElementById('marker').previousSibling;

previousSibling returns an object, if you want to get the text content of it, you can use textContent, nodeValue or wholeText property.

http://jsfiddle.net/udsZe/


Solution 3:

nextUntil will help you.. check out the link

http://api.jquery.com/nextUntil/


Post a Comment for "Jquery: Get Text Between Two
Elements"