Show hide DIVs : jQuery
- by Muhammad Sajid
Hi,
I have two links & I want to show / hide them one at a time, my code is :
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
// we will add our javascript code here
$(document).ready(function() {
$(function(){
$('#link').click(function(){
$('#colorDiv').slideToggle('slow');
return false;
});
});
});
</script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
#dv {
width:100px;
height:100px;
border:1px solid;
}
</style>
</head>
<body>
<table cellspacing="2">
<tr><td><a href="#" id="link">Color</a></td><td><a href="#" id="link">Car</a></td></tr>
<tr><td><div id="colorDiv">Red</div></td><td><div id="carDiv">PRADO</div></td></tr>
</table>
</body>
</html>
by default first div should me shown.
hanks.