Hello, I have an issue with the after() method (inserting node after another one).
index.html :
<!DOCTYPE html>
<html>
<head>
<script src="test.js"></script>
</head>
<body>
<div>
<div>
<a id="button1">button1</a>
</div>
</div>
<div>
<div>
<div>
<a id="button2">button2</a>
</div>
</div>
</div>
</body>
</html>
JS in PS plugin :
document.addEventListener("DOMContentLoaded", () => {
let b1 = document.getElementById("button1");
b1.addEventListener("click", (e) => {
let div = e.target.parentElement.parentElement;
let div2 = document.createElement("span");
div.after(div2);
});
let b2 = document.getElementById("button2");
b2.addEventListener("click", (e) => {
let div = e.target.parentElement.parentElement;
let div2 = document.createElement("span");
div.after(div2);
});
});
This works well for both buttons in chrome.
It works only for button1 in a PS plugin.
Is there something I don’t see, or is after() method buggued ?
Thank you !