我使用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");
});
请帮助!!
答案 0 :(得分:1)
$(".ntitle").click(function () {
$(".ncontent").hide(); // first hide all
$(this).parent().find(".ncontent").slideDown("fast");
});