Skip to content

Instantly share code, notes, and snippets.

@amberhinds
Created April 10, 2025 16:48
Show Gist options
  • Save amberhinds/8f66e91106a97f9f5e66270b8930c3c0 to your computer and use it in GitHub Desktop.
Save amberhinds/8f66e91106a97f9f5e66270b8930c3c0 to your computer and use it in GitHub Desktop.
Change a H5 with a specific ID to an H2 instead
// Get the <h5> element with the ID #plugin-block-heading1
const h5Element = document.getElementById('plugin-block-heading1');
if (h5Element) {
// Create a new <h2> element
const h2 = document.createElement('h2');
// Copy the content of the <h5> to the <h2>
h2.innerHTML = h5Element.innerHTML;
// Replace the <h5> element with the new <h2> element
h5Element.parentNode.replaceChild(h2, h5Element);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment