How to hide an object in javascript

Asked

Viewed 1,157 times

0

  • Because form-tab-2 is not in: /BOOT GO TO BANDEIJA/ ?

  • because it I do not want to hide it by CSS, only by javascript, I want to hide and display it with the pressing of a button that I will do in the future, but the focus of the problem is to hide the boot by javascript same

  • i did what you said by Chrome console and it even worked, but I’m trying to attach the command you said in the source code of the page, so it runs alone, thanks for the help

  • i am editing Pelop plnkr https://embed.plnkr.co/fXDmAe6uClOY80AIGwp9/ if you open will see q I pasted your command in <script> and have not had success yet

1 answer

0


Follows a way to hide this HTML element:

document.getElementById("form-tab-2").style.display = "none";

For testing: access the page URL with Google Chrome, then press F12, click "Console" option, type the above command in the console and type ENTER. inserir a descrição da imagem aqui

After typing and typing enter: inserir a descrição da imagem aqui

To apply to your Javascript and make sure that this element is not being displayed, place the code below at the beginning of your Javascript:

document.addEventListener("DOMContentLoaded", function(event) {   
    setTimeout(function(){
         document.getElementById("form-tab-2").style.display = "none"; 
    }, 1000);
});
  • I taped this command and haven’t hidden it yet

  • i’m doing it in plunkr https://embed.plnkr.co/fXDmAe6uClOY80AIGwp9/

  • understood, it really works, but I’m trying to attach this command in the source code of the page, so that at startup hide the object, still unsuccessful...

  • In Plunk it worked: put the code below at the beginning of your Javascript: Document.addeventlistener("Domcontentloaded", Function(Event) ? setTimeout(Function(){ Document.getElementById("form-tab-2").style.display = "None"; }, 1000); });

  • I edited the answer.

  • Tested it? It worked?

  • it worked yes, thanks, you did in 50 min what I’m trying to do already 1 day

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.