1. The images in the picture and the candidate information displayed are all iterated from the DataList. The purpose is to obtain the corresponding examination time, subject code and other information by clicking the mark button.
To achieve this, click the mark button to send the current candidate's information back to the background for processing. How does JS get the detailed information of the current handwriting card? These pictures are dynamically iterated and have no fixed ID and name. JQuery does not know how to obtain unique picture-related information.
Page code:
<asp:DataList ID="DataList1" runat="server" RepeatColumns="2">
<ItemTemplate>
<p class="col-lg-12">
<p class="col-md-4 kmdm" style="margin-top: 5px">科目代码:<%#Eval("TJ_KM_DM")%></p>
<p class="col-md-4 kssj" style="margin-top: 5px">考试时间:<%#Eval("KSSJ") %></p>
<p>
<input class="jddz" type="text" value="<%#Eval("KSSJ").ToString()+Eval("TJ_KM_DM").ToString().Trim()+Eval("KS_ZKZ")%>" /></p>
<p class="col-md-4">
<input style="margin-bottom: 5px" value="未标记" class="chexSign btn btn-success" type="button" onclick="signCard(this)" /></p>
<img src="../../img/200701/0094/010207301376.jpg" alt="Responsive image" class=" well well-lg img-responsive img-thumbnail " />
</p>
</ItemTemplate>
</asp:DataList>
通常的做法,在动态生成 dom 的时候, 同时生成数据标志,例如 data-index = 'KSSJ', jquery 动态绑定 click 事件的时候,用 $(e.currentTarget).data('index')获取。其它字段也都可以通过 e 这个对象获取到,详细属性答主可以 console.log(e) 浏览。