尝试获取生成的复选框ID
当前复选框代码
<asp:CheckBox ID="CheckBox_select" type="checkbox" runat="server" onclick="javascript:CheckCheckBox(this);" />
生成:
<input id="ContentPlaceHolder1_GridView_reminderList_CheckBox_select_10" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView_reminderList$ctl12$CheckBox_select" onclick="javascript:CheckCheckBox(this);">
<input id="ContentPlaceHolder1_GridView_reminderList_CheckBox_select_11" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView_reminderList$ctl11$CheckBox_select" onclick="javascript:CheckCheckBox(this);">
如何获取ContentPlaceHolder1_GridView_reminderList_CheckBox_select_10&amp;在JavaScript中甚至在asp.net中的ContentPlaceHolder1_GridView_reminderList_CheckBox_select_11?
答案 0 :(得分:0)
阅读
Element.id
属性
function CheckCheckBox(elem) {
console.log(elem.id);
}
&#13;
<input id="ContentPlaceHolder1_GridView_reminderList_CheckBox_select_10" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView_reminderList$ctl12$CheckBox_select" onclick="javascript:CheckCheckBox(this);">
<input id="ContentPlaceHolder1_GridView_reminderList_CheckBox_select_11" type="checkbox" name="ctl00$ContentPlaceHolder1$GridView_reminderList$ctl11$CheckBox_select" onclick="javascript:CheckCheckBox(this);">
&#13;