so i have this code...that includes three buttons in each div, and i only want to show one div at a time. so when i click a div1, the other divs will not open and when div1 is currently is opened, when i click the div2, div1 will close and div2 is now the current div opened and so on..
is it possible that i will not create multiple functions for each div, and change my div class and button class will be retained as much as possible....??
here is my code i just got this js from the net too...
i would really appreciate your help guys....
is it possible that i will not create multiple functions for each div, and change my div class and button class will be retained as much as possible....??
here is my code i just got this js from the net too...
Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(".slidingDiv").hide(); $(".show_hide").show(); $('.show_hide').click(function(){ $(".slidingDiv").slideToggle(); }); }); </script> <button class="show_hide"> Add New</button> <br /> <div class="slidingDiv"> <form action="" name="add" method="post"> </strong> <tr> <td>form1:</td> <td width="225"><input type="text" name="amount" value="" /> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" value="Reset"> </td> </tr> </form> </div> <button class="show_hide">Add New</button> <br /> <div class="slidingDiv"> <form action="" name="add" method="post"> </strong> <tr> <td>form2</td> <td width="225"><input type="text" name="amount" value="" /> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" value="Reset"> </td> </tr> </form> </div> <button class="show_hide">Add New</button> <br /> <div class="slidingDiv"> <form action="" name="add" method="post"> </strong> <tr> <td>form3</td> <td width="225"><input type="text" name="amount" value="" /> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" value="Reset"> </td> </tr> </form> </div>
Comment