Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="pt-br">
- <head>
- <title>Esconder e Mostrar Elementos</title>
- <style>
- #conteudo{
- width: 400px;
- height: 300px;
- border: 1px solid black;
- margin-top: 5px;
- padding: 10px;
- background-color: lightgreen;
- }
- </style>
- <script>
- function esconde(el) {
- document.getElementById(el).style.display = 'none';
- }
- function mostra(el) {
- document.getElementById(el).style.display = 'block';
- }
- function toggle(el) {
- var display = document.getElementById(el).style.display;
- if(display == "none"){
- document.getElementById(el).style.display = 'block';
- }
- else{
- document.getElementById(el).style.display = 'none';
- }
- }
- </script>
- </head>
- <body>
- <h3>Esconder e Mostrar Conteúdos com JS</h3>
- <button onclick="esconde('conteudo')">Esconder</button>
- <button onclick="mostra('conteudo')">Mostrar</button>
- <button onclick="toggle('conteudo')">Alternar</button>
- <div id="conteudo">
- JavaScript é uma linguagem de programação interpretada estruturada,
- de script em alto nível com tipagem dinâmica fraca e multiparadigma.
- Juntamente com HTML e CSS, o JavaScript é uma das três principais
- tecnologias da World Wide Web.
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment