如何防止点击标题列
如何防止标题列中的点击事件。如何防止点击标题列
HTML:
<table> <tr>
<th class="column">Header</th>
</tr>
<tr>
<td class="column">Body 1</td>
</tr>
<tr>
<td class="column">Body 2</td>
</tr>
<tr>
<td class="column">Body 3</td>
</tr>
</table>
然后我的脚本
$('.column:not("th")').on('click', function(){ alert("test");
});
回答:
为什么不:
$('td.column').on('click', function(){ alert("test");
});
回答:
- 哟添加TBODY选择ü代码
$('tbody .column').on('click', function() { alert("test");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table>
<thead>
<tr>
<th class="column">thead</th>
</tr>
<tr>
<th class="column">thead Body 1</th>
</tr>
<tr>
<th class="column">thead Body 2</th>
</tr>
<tr>
<th class="column">thead Body 3</th>
</tr>
</thead>
<tr>
<td class="column">Header</td>
</tr>
<tr>
<td class="column">Body 1</td>
</tr>
<tr>
<td class="column">Body 2</td>
</tr>
<tr>
<td class="column">Body 3</td>
</tr>
</table>
以上是 如何防止点击标题列 的全部内容, 来源链接: utcz.com/qa/260543.html