jQuery .next() and .prev() not working as they should!
Posted
by Luca Matteis
on Stack Overflow
See other posts from Stack Overflow
or by Luca Matteis
Published on 2010-04-27T11:27:55Z
Indexed on
2010/04/27
11:43 UTC
Read the original article
Hit count: 205
I want to get the .next()
and .prev()
sibling of an HTML element without excluding TextNodes.
I basically need to understand if an element is directly sorrounded by <br>
HTML elements.
This would return true:
<br>
<div></div>
<br>
This would return false:
<br>
Some text
<div></div>
<br>
BUT this needs to also return true:
<br>
<div></div>
<br>
The third example basically uses an empty TextNode, or blankspaces, or newlines.
What's the best way to do this?
© Stack Overflow or respective owner