dom - How to do insert After() in JavaScript without using a library? -


there's insertbefore() in javascript, how insert after element without using jquery or other library?

referencenode.parentnode.insertbefore(newnode, referencenode.nextsibling); 

where referencenode node want put newnode after. if referencenode last child within parent element, that's fine, because referencenode.nextsibling null , insertbefore handles case adding end of list.

so:

function insertafter(newnode, referencenode) {     referencenode.parentnode.insertbefore(newnode, referencenode.nextsibling); } 

try here.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -