im trying to get some text without having any wrapping element, a example is:
<div class="theme">
<h3>Title</h3>
Get text here
<table>
...
</table>
</div>
Thats basically the structure of the html, im tyring to figure out how to get the text "Get text here", is there any helpfull funcition in jquery to make this task easyer?
>Solution :
These kinds of objects are known as node in JavaScript. nextSibling and prevSibling properties show next and previous node. for example, you can find h3 and then use nextSibling or find the table and then use prevSibling (as the following code).
For nodes wholeText property is the same as innerText and gives the content of the node.
var h3 = document.querySelector('h3');
console.log(h3.nextSibling)
console.log(h3.nextSibling.wholeText)