Widget:RemoveParserOutputParentDiv: Difference between revisions

From Tsadra Commons
((by SublimeText.Mediawiker))
((by SublimeText.Mediawiker))
Line 18: Line 18:


unwrapElementsByClass('mw-parser-output', 'remoteValue');
unwrapElementsByClass('mw-parser-output', 'remoteValue');
</script>
</script>

Revision as of 18:29, 14 February 2025

<script> function unwrapElementsByClass(className, parentId) { const container = document.getElementById(parentId); if (!container) return;

const elements = container.getElementsByClassName(className);

// Convert to array since we'll be modifying the live HTMLCollection Array.from(elements).forEach(element => { // Move all children before the wrapper while (element.firstChild) { element.parentNode.insertBefore(element.firstChild, element); } // Remove the empty wrapper element.parentNode.removeChild(element); }); }

unwrapElementsByClass('mw-parser-output', 'remoteValue'); </script>