我的问题是我想在data-list控件中打开div onclick锚标签。我在Google上搜索以达到此功能,但无法正常工作
(当我单击锚标记时,不要打开div。)我想知道为什么。
$( function () {
$('a.detials').on('click', function (ev) {
$(this).next('div').toggle();
});
});
<asp:DataList ID="dtlRoomsPrice" Visible="false" orizontalAlign="center" runat="server" ShowFooter="False" ShowHeader="False" Width="700px" OnItemDataBound="dtlRoomsDetails_ItemDataBound">
<ItemTemplate>
<a href="javascript:void(0);" class="detials">ShowDetails</a>
<div class="shoow" id="div_ID" style="width:687px;background-color: rgb(247, 239, 216);border-radius: 5px;box-shadow: 7px 6px 5px #888888; border: 2px solid gray; display:none;padding: 5px; ">
<asp:Label ID="lblAmiintiesTxt" runat="Server" CssClass="shbe_label" Text="<%$ Resources:Resource,Amenities %>" Visible="false"></asp:Label>
<p style="margin-top: 0px;margin-bottom: 0px;font-family: sans-serif; font-weight: bold; font-size: small;">Amenities</p>
<asp:Label ID="lblAmiinties" runat="Server" CssClass="shbe_h2" Text='<%# Eval("Amenities") %>' Visible="true"></asp:Label>
<br />
<asp:Label ID="lblCanclText" Width="130" runat="server" CssClass="shbe_label" Visible="false" Text="<%$ Resources:Resource, Payment and Cancellation policy %>"></asp:Label>
<p style="margin-bottom: 0px;font-family: sans-serif; font-weight: bold; font-size: small;">CancellationPolicy</p>
<asp:Label ID="lblCancelation" runat="Server" CssClass="shbe_h2" Text='<%# Eval("CancellationPolicyText") %>' Visible="true"></asp:Label>
</div>
</ItemTemplate>
</asp:DataList>
最佳答案
尝试一下。会的。
$(function () {
$(document).on("click",'a.detials', function (ev) {
$(this).next('div').toggle();
});
});