In fiddle - http://jsfiddle.net/u3bmytnL/, does not work as expected
var x = document.createElement("button");
x.textContent = "byyyyy";
elx = document.getElementById("el");
elx.insertAdjacentHTML('afterend', x);
That's should resolve:
var x = document.createElement("BUTTON");
var text = document.createTextNode("byyyy");
x.appendChild(text);
elx = document.getElementById("el");
elx.insertAdjacentHTML('afterend', x.outerHTML);
The insertAdjacentHTML needs a string as second parameter, and you was passing a DOM element, so you need to get the HTML string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With