2015-01-21 48 views
-1

調用內部中繼器的jquery函數問題我想切換div時單擊linkbutton。我認爲不是第一個jquery函數用於這種情況。 我想也是從div和鏈接按鈕之間的表probelem。調用中繼器內部的jQuery函數

function toggleMe() { 
     $(function() { 
      $('.toggler').on('click', function (ev) { 
       $(this).next('.dataContentSection').toggle(); 
      }); 
     }); 
     } 
<div id="repeater"><div class="dataContentSection"> 
    <div>Name</div> 
</div> 

     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label1" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label2" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label3" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label4" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label5" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
</div> 
+0

最新問題? – atmd 2015-01-21 08:26:59

+0

那麼你想實現什麼?當我點擊「地址詳情」時,鏈接應該打開?請給我們正確的細節 – BNN 2015-01-21 08:27:34

+0

當我點擊linkbutton打開div。 – boshkash 2015-01-21 08:28:32

回答

0

問題是toggleMe()功能。 如果你想div的來回切換,你需要做這樣的事情: -

$(function() { 
     $('.toggler').click(function (ev) { 
      $(".dataContentSection").toggle(); 
      $(this).next('.dataContentSection').toggle(); 
     }); 
    }); 

希望這有助於。

+0

以及我在onclientclick事件按鈕 – boshkash 2015-01-21 08:50:25

+0

中做什麼我認爲你不需要這個。它正在工作'onClick'的按鈕 – BNN 2015-01-21 08:54:32

+0

,因爲後期打開所有div的 – boshkash 2015-01-21 08:57:11