如何验证值是否来自HTML

时间:2016-10-27 21:57:40

标签: javascript jquery

以下是我的HTML网页的代码段:

<div id="top">
            <button type="button" name="ptmBtn" id="ptmBtn">PTM</button>
</div>
<div id="bottomleft">
    <b>Contact List</b>
        <table id="cntList">
			<tr>
				<td> <input type="checkbox" name="checkbox"> </td>
				<td> Aniruddh </td>
			</tr>
			<tr>
				<td> <input type="checkbox" name="checkbox"> </td>
				<td> Ajay <td>
			</tr>
			<tr>
				<td> <input type="checkbox" name="checkbox"> </td>
				<td> Vijay </td>
			</tr>
        </table>
</div>
<div id="bottomRight">
    <b>Group List</b>
        <table id="grpList">
			<tr>
				<td> <input type="checkbox" name="checkbox"> </td>
				<td> Group1 </td>
			</tr>
			<tr>
				<td> <input type="checkbox" name="checkbox"> </td>
				<td> Group2 <td>
			</tr>
        </table>
</div>

我正在开发一个Web应用程序,只需按一下按钮就可以向用户发送消息。我的页面上有两个HTML表格,即“id”=“cntList”和“id”=“grpList”组的联系人;其中两个表都有名称和一个对应的复选框。

当我点击Contacts表中的某个联系人或Group表中的一个组时,我的代码应该知道它是来自Contacts表还是Group表,并调用该函数来相应地发送消息。

我正在讨论如何从这开始使用JQuery?

1 个答案:

答案 0 :(得分:2)

您可以通过id的{​​{1}}属性或table使用{{{}来检索事件处理程序中已点击的父.id元素的this 1}} event.currentTarget作为选择器传递,.closest() table[id$=List]作为参数

.attr()
"id"

相关问题