Using jQuery, is it possible to change all matched elements to a different type?
For example, can I select all a
tags, $(\"a\")
, and change
Using standard JavaScript's ChildNode.replaceWith() method can do this. Run example.
var element = document.querySelector("span");
var elementInnerHTML = element.innerHTML;
var newElement = document.createElement("h1");
newElement.innerHTML = elementInnerHTML;
element.replaceWith(newElement);
hightekk.com
Hello World