Show/Hide button

Asked

Viewed 7,315 times

-4

how do I create a show and hide button in Java and it leaves the content hidden already when I open the page. and I just click first to show and then to hide.

  • Post the code of what you’ve already done.

  • 8

    Possible duplicate http://answall.com/questions/45832/comor-alternatetexto-entre-mostrar-esconder-dentro-de-um-button-com-javascrip

1 answer

0


I think that’s what you want:

Hide() hides the div when the page ends loading. toggle() is triggered by the button displaying and hiding the div

<html>
<head runat="server">
    <title></title>
</head>

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
    $(document).ready(function (e) {
        $("#divConteudo").hide();

        $("#btnMostrarEsconder").click(function (e) {
            $("#divConteudo").toggle();
        });
    });
</script>

<body>
    <div id="divConteudo">
        Conteudo
    </div>
    <button id="btnMostrarEsconder" type="button">Mostrar e Esconder</button>
</body>
</html>

Browser other questions tagged

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