[英]Get the input of a DIV row with a button click
我正在动态绑定 div。 请看下图。 当我单击更新按钮时,我需要获取当前行单元格值。 我如何通过 jQuery 或 JavaScript 实现这一点? 我试过这种方式 var InputVal = $(this).closest('.row');
<div class="Row">
<input type="hidden" id="hid_2167" value="200">
<div class="Cell2">eztest</div>
<div class="Cell1" id="edit_2167_8053" style="display: table-cell;">
<input class="text-box single-line" data-val="true" data-val-length="The must not be blank" data-val-length-max="20" id="DeviceMappingList_12__FirstName" name="DeviceMappingList[12].FirstName" type="text" value="j"></div>
<div class="Cell" id="disp_2167_8053" style="display: none;">
j
</div>
<div class="Cell1" id="edit_2167_8053" style="display: table-cell;">
<input class="text-box single-line" data-val="true" data-val-length="The field LastName must be a string with a maximum length of 20." data-val-length-max="20" id="DeviceMappingList_12__LastName" name="DeviceMappingList[12].LastName" type="text" value="d"></div>
<div class="Cell" id="disp_2167_8053" style="display: none;">
d
</div>
<div class="Cell1" id="edit_2167_8053" style="display: table-cell;">
<input class="text-box single-line" data-val="true" data-val-length="The field Email must be a string with a maximum length of 30." data-val-length-max="30" id="DeviceMappingList_12__Email" name="DeviceMappingList[12].Email" type="text" value="jd"></div>
<div class="Cell" id="disp_2167_8053" style="display: none;">
jd
</div>
<div class="Cell1" id="edit_2167_8053" style="display: table-cell;"><input class="text-box single-line" data-val="true" data-val-length="The field MobileNumber must be a string with a maximum length of 20." data-val-length-max="20" id="DeviceMappingList_12__MobileNumber" name="DeviceMappingList[12].MobileNumber" type="text" value="085"></div>
<div class="Cell" id="disp_2167_8053" style="display: none;">
085
</div>
<div class="Cell">
Alan
<input id="DeviceMappingList_12__UserName" name="DeviceMappingList[12].UserName" type="hidden" value="Alan">
</div>
<div class="Cell1" id="edit_2167_8053" style="display: table-cell;"><input altid="hid_2167" checked="checked" data-val="true" data-val-required="The IsActive field is required." id="DeviceMappingList_12__IsActive" name="DeviceMappingList[12].IsActive" onclick="return checkrows(this)" type="checkbox" value="true"><input name="DeviceMappingList[12].IsActive" type="hidden" value="false"></div>
<div class="Cell" id="disp_2167_8053" style="background-color: lightgreen; display: none;">
<a href="#" onclick="changeDeviceStatus(2167,8053,'True','eztest')">Deactivate</a>
</div>
<div class="Cell2">21/11/2019 09:49:12</div>
<div class="Cell2">9DF2573B-DEF7-455C-9625-517DBED8556F</div>
<div class="Cell2">2.3.23</div>
<div class="Cell2">13.3.1</div>
<div class="Cell2">iPad (5th Gen) (Wi-F</div>
<input style="display:none" type="checkbox" name="chkdeviceId" id="chkdeviceId" chkid="chk_2167_8053" value="8053">
<input style="display:none" type="checkbox" name="chkcompanyId" id="chkcompanyId" chkid="chk_2167_8053" value="2167">
<div class="Cell3">
<a href="" id="aedit" onclick="return editDeviceDetails(this,2167,8053)">cancel</a>
<a href="#" style="display: block;" id="update_2167_8053" onclick="updatedevicedetails(2167,8053,eztest,j,d,jd,085 )">Update</a>
<a href="" id="adelete" onclick="return deleteDevice(this,2167,8053,'eztest','iPad (5th Gen) (Wi-F')">delete</a>
</div>
</div>
我得到了这段代码并解决了。 谢谢 !
var row = $(this).closest('.Row');
console.log(row.find('[id*=__FirstName]').val());
console.log(row.find('[id*=__LastName]').val());
console.log(row.find('[id*=__Email]').val());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.