我的问题是我想打开div,点击数据列表控件中的锚标签。我在谷歌搜索到达此功能,但它无法正常工作 (当我点击锚标签时,不要打开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>
答案 0 :(得分:0)
$(function () {
$(document).on("click",'a.detials', function (ev) {
$(this).next('div').toggle();
});
});