Jump to content

Recommended Posts

Posted

Boa tarde a todos, 

estou com um pequeno erro num certo código javascript.

Eu tenho uma div, que quando a página carrega deve estar invisível, e quando carrego num botão ele fica visível. 

A página carrega, a div não aparece, só que quando carrego no botão ela aparece e volta a desaparecer.

Os meus códigos são os seguintes:

JS

    <script>
        function togglediv(id) {
            var div = document.getElementById(id);
            div.style.display = div.style.display == "block" ? "none" : "block";
        }
    </script>

HTML

<button onclick="togglediv('painel_secundario1')">Ver</button>

<div id="painel_secundario1" style="display: none;">

Obrigado a todos que ajudarem.

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.