I have a simple jQuery code for toggle. I want to apply it in multiple <div>s as more I need.
here is the code:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle(500);
});
});
</script>
<style type="text/css">
#panel,#flip
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#panel
{
padding:50px;
display:none;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#flip1").click(function(){
$("#panel1").slideToggle(500);
});
});
</script>
<style type="text/css">
#box1
{ margin:10px;
height:auto;
}
#panel1,#flip1
{
padding:5px;
text-align:center;
background-color:#e5eecc;
border:solid 1px #c3c3c3;
}
#panel1
{
padding:50px;
display:none;
}
</style>
</head>
<body>
<div id="flip">Click to slide the panel down or up</div>
<div id="panel">Hello world!</div>
<div id="box1">
<div id="flip1">Click to slide the panel down or up</div>
<div id="panel1">Hello world!</div>
</div>
</body>
</html>
I want same box for multiple times. For example if I add another panel to apply sliding drop down effect what would the way to do that? I need more panels.
here is the jsbin link: http://jsbin.com/usafir/1