Created
September 19, 2019 18:14
-
-
Save porfidev/13174f2bc035c323b99ac8f74d4c0e25 to your computer and use it in GitHub Desktop.
Refactor de tutorial #1 Mostrar y Ocultar Divs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Tutorial jQuery Remasterizado</title> | |
<link href="style.css" rel="stylesheet"> | |
</head> | |
<body> | |
<button id="showContainer" type="button">Mostrar mensaje</button> | |
<button id="hideContainer" type="button">Ocultar mensaje</button> | |
<div class="container hidden"> | |
Esta div se esta mostrando sin embargo puede ser cualquier elemento | |
</div> | |
<script | |
src="https://code.jquery.com/jquery-3.4.1.min.js" | |
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" | |
crossorigin="anonymous" | |
></script> | |
<script> | |
$(window).on("load", assignEvents); | |
function assignEvents() { | |
$("#showContainer").on("click", mostrar); | |
$("#hideContainer").on("click", ocultar); | |
} | |
function mostrar() { | |
$("div").show("slow"); | |
} | |
function ocultar() { | |
$("div").hide("slow"); | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container { | |
background-color: #9c0; | |
border-color: #063; | |
border-style: dotted; | |
border: thin; | |
width: 200px; | |
height: 200px; | |
} | |
.hidden { | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment