当选择行如何删除所有同级别表行CSS类? [英] How to remove a CSS class from all same level table rows When a Row is Selected?

查看:149
本文介绍了当选择行如何删除所有同级别表行CSS类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$('table tbody tr').click(function () {
            // how to remove clickedRow class from all same level rows?
            $(this).addClass('clickedRow');
        });

在选择一排,我想从同一个表的所有其他行删除clickedRow css类,只把它添加到当前所选行。

When a row is selected, I'd like to remove the clickedRow css class from all other rows of the same table and only add it to the currently selected row.

有比表更我的网页,以便每次点击只能在同一个表的情况下做如上。

there are more than table in my page so each click should do as above only in the context of the same table.

怎么会是这样可能吗?

谢谢,

推荐答案

您可以使用此:

$('table tbody tr').click(function () {
    $(this).siblings().removeClass('clickedRow');
}

这将从所有兄弟行删除您的CSS类

it will remove your css class from all sibling rows

这篇关于当选择行如何删除所有同级别表行CSS类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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