当我有这样的功能时,如何获取被点击的元素的 id?
$("#btnOne, #btnTwo").on("click", "input.select", function () {
我试过:
this.id;
和
$(this).attr("id");
这是html
<div id="TransferOwnershipBox" title="Transfer Ownership">
<table>
<tr>
<td>
<asp:TextBox ID="tbSearchField" Text="Search..." ClientIDMode="Static" Width="400px" runat="server" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
</td>
<td>
<input type="button" id="btnSearch" data-str="tblOwnerSearchResults" value="Search" Class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
</td>
</tr>
</table>
<table id="tblOwnerSearchResults" data-str="ownerId" data-dataItem="id" style="border: none; width: 100%; padding: 2px;"></table>
</div>
<!-----COURSE DIRECTOR----->
<div id="CourseDirectorBox" title="Directors">
<table>
<tr>
<td>
<asp:TextBox ID="tbDirector" Text="Search..." ClientIDMode="Static" Width="400px" runat="server" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
</td>
<td>
<input type="button" id="btnDirectorSearch" data-str="tblDirectorSearchResults" value="Search" Class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
</td>
</tr>
</table>
<table id="tblDirectorSearchResults" data-str="source" data-dataItem="DisplayName" style="border: none; width: 100%; padding: 2px;"></table>
</div>
但我也没有得到任何身份。
谢谢