在 jquery 中制作表格行而不是表格标题 [英] Making table rows but not table headers clickable in jquery

查看:26
本文介绍了在 jquery 中制作表格行而不是表格标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在使用

$('#mytable tr').click(function() {
    blah blah
});

这使得所有行,包括标题都可以点击.如何排除标题或 的标题?

This makes all rows, including the headers clickable. How can I exclude the headers or <th>'s?

推荐答案

使用 标签将标题和正文分开,并更改你的选择器 "#mytable tbody tr"

Separate you header and body using <thead> and <tbody> tags, and change your selector to "#mytable tbody tr"

HTML 看起来像这样

HTML will look something like this

<table> 
    <thead>
        <tr>
         ...
        </tr>
    </thead>
    <tbody>
         <tr>
            ...
         </tr>
    </tbody>
</table>

这篇关于在 jquery 中制作表格行而不是表格标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆