En este ejemplo de código vamos a aprender cómo mostrar / ocultar Div usando jQuery – una función activar (). Vamos a mostrar y ocultar div en el botón de clic.
jQuery Fragmento de código – Mostrar / Ocultar Div en el botón Haga clic
jQuery / JavaScript
<!--jQuery to show/hide div-->
<script type="text/javascript">
$(document).ready(function(){
$("#btnShowHide").click(function(){
$("#divShowHide").toggle();
});
});
</script>
Código fuente HTML con jQuery / JavaScript
<!--jQuery - Show/Hide Div on Button Click using jQuery.-->
<html>
<head>
<title>jQuery - Show/Hide Div on Button Click using jQuery.</title>
<!--Example CSS-->
<link href="ExampleStyle.css" type="text/css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--jQuery to show/hide div-->
<script type="text/javascript">
$(document).ready(function(){
$("#btnShowHide").click(function(){
$("#divShowHide").toggle();
});
});
</script>
</head>
<body>
<h1>jQuery - Show/Hide Div on Button Click using jQuery.</h1>
<p><input type="button" value="Show/Hide" id="btnShowHide"/></p>
<div id="divShowHide" style="background-color: #fff; width: 100px; height: 100px;">
Welcome to IncludeHelp.
</div>
</body>
</html>
Resultado
clic for DEMO y rarr;