Dhanush Bala Dhanush Bala - 2 months ago 7
HTML Question

find the previous is textnode from classname

<p>
<ins>this is sample text</ins> here text node
<span class='cursor'></span><ins>last word</ins>
</p>


$('.cursor').prev()


is returning the previous
ins
tag.

How to find
span.cursor
before
here text node
?

Answer

You can use

$('.cursor')[0].previousSibling