在asp.net中使用jquery在datalist中切换单个项目

时间:2015-03-10 05:16:35

标签: javascript jquery asp.net

我使用datalist显示数据库中的标题,并隐藏了它的内容。当点击每个项目时,我想显示它的隐藏内容。我正在使用jquery。这就是我试过的到目前为止。

Datalist中

 <asp:DataList ID="dl_news" runat="server">
 <ItemTemplate>
     <asp:Label class="ntitle" runat="server"   Text='<%#Eval("title")%>'>  </asp:Label> </br>
     <asp:Label class="ncontent" runat="server"  style=" display:none; " Text ='<%#Eval("ncontent")%>'>  </asp:Label>
</ItemTemplate>

  </asp:DataList>

这是jquery

 $(".ntitle").click(function () {

         $(".ncontent").hide(); // first hide all
         $(this).next(".ncontent").slideDown("fast");
    });

请帮助!!

1 个答案:

答案 0 :(得分:1)

$(".ntitle").click(function () {

         $(".ncontent").hide(); // first hide all
         $(this).parent().find(".ncontent").slideDown("fast");
    });
相关问题