How can I find the next element in the current scope? For example, I want to find div
element and after this the next one which is p
?
If I use document.getElementsByTagName('DIV')[0].nextSibling
it returns #text
. I want it to return p
tag.
<div>
<table>
<tr>
<td></td>
</tr>
</table>
</div>
<p></p>
You can use nextElementSibling
. If you need to support older browsers, traverse nextSibling
until you find an Element node.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments