a simple jQuery example

How to Hide, Show and Toggle Elements With jQuery

How to Hide, Show and Toggle Elements With jQuery

Click here to see the demo

The Code :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hide Show Toggle with jQuery</title>
<script type="text/javascript" src="jquery-1.7.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#show").click(function() {
$("#box").show("slow");
});
$("#hide").click(function() {
$("#box").hide(3000, function() {
alert("We just hide the div!");
});
});
$("#toggle").click(function() {
$("#box").toggle("normal");
});
});
</script>
<style>
#box {
width:300px;
height: 300px;
border:2px solid #000;
background-color:#F00;
}
</style>
</head>

<body>
<div id="box"></div>

<form>
<a href="#" id="hide">Hide</a> -

<a href="#" id="show">Show</a> -

<a href="#" id="toggle">Toggle</a>

</form>
</body>
</html>





Leave a Reply

Your email address will not be published. Required fields are marked *