I dynamically create some a tags with JavaScript when clicking on other elements. When I refresh the page, the created elements disappear. Is there a way to store the creation of the elements in a JavaScript cookie?
function showTab(ev) {
let head = document.getElementById('heading');
let node = document.createElement("a");
node.classList.add("tab");
node.appendChild(document.createTextNode(ev.target.innerHTML));
head.appendChild(node);
};
When I refresh the page, the created elements disappear.Sure. It's designed by all the browsers.outerHTMLof the tag. When the page is loaded, check the cookie contains some tag or not. If contains, override it. If you are going to use cookie, make the string as short as possible before saving.