2014-01-18 51 views
1

有人可以幫我解決我的問題,使用jQuery slideToggle。我想的slideToggle DIV使用1個按鈕,但似乎不工作jQuery slideToggle div使用1按鈕

這裏:

<script type="text/javascript"> 
    $("#btnaddphone").click(function() { 
     $("#togbap").hide(); 
     $("#togbap").slideToggle(); 
    }); 
</script> 

<div id="AddPhone"> 
       <table> 
       <tr> 
        <td width="300" height="150" style="text-align:left"> 
        <asp:Button ID="btnaddphone" runat="server" Text="+" OnClientClick="return false;" /> 
        <asp:Label ID="lbbus10" runat="server" Text="Add Phone"></asp:Label> 
        <div id="togbap"> 
        <table> 
        <tr> 
         <td><asp:Label ID="aplandline" runat="server" Text="Landline work"></asp:Label></td> 
         <td><asp:TextBox ID="aptxt1" class="basetxt" runat="server" ></asp:TextBox></td> 
        </tr> 
        <tr> 
         <td><asp:Label ID="aphppersonal" runat="server" Text="Handphone personal" ></asp:Label></td> 
         <td><asp:TextBox ID="aptxt2" class="basetxt" runat="server"></asp:TextBox></td> 
        </tr> 
        <tr> 
         <td><asp:Label ID="aphpwork" runat="server" Text="Handphone work"></asp:Label></td> 
         <td><asp:TextBox ID="aptxt3" class="basetxt" runat="server"></asp:TextBox></td> 
        </tr> 
        </table> 
        </div></td> 
        <td width="300"></td> 
       </tr> 
       </table> 
       </div> 

它的對話框BTW

回答

2

首先地方里面的文件代碼準備的內部。其次,在點擊事件之前放置隱藏代碼,或者在點擊事件中使用slideToggle來實現相同的操作。

<script type="text/javascript"> 
    $(document).ready(function() { 
    $("#togbap").hide(); 
    $("#btnaddphone").click(function() { 
     $("#togbap").slideToggle(); 
    }); 
    }); 
</script> 
+0

現在這個工作謝謝@themosquitokiller –