George Duckett George Duckett - 1 year ago 68
Javascript Question

void custom element being altered when calling parentelement.innerHTML to get the DOM

I am using javascript to transform the DOM, which includes a custom tag (that I can't control the name of).
I then call

on the parent element to get the transformed DOM as a string. My issue is that the simply doing this the DOM changes, I'm assuming because of the custom tag.

See below for a minimal example. Ignore the extra script bit that gets added by the snippet plumbing, the point is that the pagebreak tag now wraps

How can I prevent this, and preserve the DOM while going through an


<mbp:pagebreak />test

Answer Source

A custom element is non-void, and so you should specify a closing tag, like this:

<div id="test">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download