Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How To Set Display None of <footer> tag with Console?

I’m trying to hide some fields on sites with javascript. For this, I use the console of the relevant browser and here I make that field display = "none"; with ClassName or ID, but I made a few attempts to improve these things a little more.

In these experiments, I only found a field with <footer> tag, but it has neither ClassName nor ID.

document.getElementsByClassName("footer")[0].style.display = "none";

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I make it invisible with js code? Thank you very much if you can get back to me. I am trying to learn something new.

>Solution :

You can use the document.querySelector() function. This allows you to specify any valid CSS selector, meaning that in this case you can use the element’s tag type to identify it.

Demo:

document.querySelector("footer").style.display = "none";
<div>Another div</div>
<footer>Hello</footer>

The code will remove the existing "Hello" message by hiding the footer element. All that’s still on display is the "Another div".

Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading