高亮表格行或列

今天学习jQuery,练习一下对表格进行列或行高亮显示。

我们对下面这个表格来进行。代码是写在ASP.NET MVC程序上Razor语法。




这个需要符合某一条件:只要控制器列的文本为:Railway。

首先添加样式:

 .highTransport {
        background-color: #0915f3 !important;
        color: #ffffff !important;
    }
Source Code

只亮某一td:

$(".trData td.controller").filter(function () {
            return $(this).text() == 'Railway';
        }).addClass('highTransport');
Source Code


效果:

另一种情形,需要高亮整行:

$(".trData").filter(function () {
            return $(this).find('.controller').text() == 'Railway';
        }).addClass('highTransport');
Source Code

 运行效果:

原文地址:https://www.cnblogs.com/insus/p/6526441.html