I want to hide the parent element of the element 'child'. It will be better. Do anyone know to do this with pure css. If there is no way to do so.. JavaScript is also Ok for me
Code
<h2>
<span id="child">
Lorem Ipsum
</span>
</h2>
I want to hide the parent element of the element 'child'. It will be better. Do anyone know to do this with pure css. If there is no way to do so.. JavaScript is also Ok for me
Code
<h2>
<span id="child">
Lorem Ipsum
</span>
</h2>
document.addEventListener( 'DOMContentLoaded', function() {
for( const el of document.querySelectorAll( '.child' ) ) {
const ancestorH2 = el.closest( 'h2' );
if( ancestorH2 ) ancestorH2.style.display = 'none';
}
} );
Maybe something like this in js?
var x = document.getElementById("child").parentElement;
x.style.display = 'none';