国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - How does JQuery get the ID of the current element through the dot mark button (how to get the ID of dynamic data)
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-05-19 10:18:00
0
2
851

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">考試時(shí)間:<%#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="未標(biāo)記" 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>
PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證0級(jí)講師

reply all(2)
我想大聲告訴你
function signCard(item){
    var parentp = $(item).parents(".col-lg-12"); // 外層的 p
    var time = parentp.find(".kssj").text(); // 這里取你想要的信息
    console.log(time);
}

parent() 取直接父級(jí)元素
parents() 取所有祖先元素
世界只因有你

The usual practice is to generate data flags when dynamically generating dom, such as data-index = 'KSSJ', when jquery dynamically binds click events, use $(e.currentTarget).data('index') to obtain . Other fields can also be obtained through the e object, and detailed attributes can be browsed using console.log(e).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template