效果演示图:

JS 代码如下:

function TableHover($table){

      $table.mouseenter(function(event) {
            var xIdx = 0, yIdx = 0;
            $table.each(function(index, el) {
                  $(this).removeClass('hover');
            });

            $(this).addClass('hover').siblings().removeClass('hover');
            $table.each(function(index, el) {
                  if($(this).hasClass('hover')){
                  xIdx = $(this).index();
                  yIdx = $(this).parent().index();
                  }
            });
            if(xIdx>0){
                  for(var i = 0; i < xIdx; i++) {
                      $(this).parent().children().eq(i).addClass('hover');
                  }
                 for(var i = 0; i < yIdx; i++) {
                     $(this).parent().parent().children().eq(i).children().eq(xIdx).addClass('hover');
                 }
             }

       });
      $table.mouseout(function(event) {
            $table.each(function(index, el) {
                 $(this).removeClass('hover');
            });
      });

}

export default TableHover;

调用:TableHover($('.table-container table td'));

CSS类:

table tr td.hover {
  background-color: $gray250;
  color: $white-color;
}
table tr td:nth-child(1).hover {
  background-color: $gray300;
  color: $white-color;
}
table tr td.th_title.hover {
  background-color: $gray300;
  color: $white-color;
}

td:hover{
  background: $gray500 !important;
  color: $white-color;
}

HTML代码:

<table style="overflow-x: auto;">
  <tbody>
    <tr>
      <td class="th_title">Label</td>
      <td class="th_title">US</td>
      <td class="th_title">UK</td>
      <td class="th_title">AU</td>
      <td class="th_title">EU</td>
      <td class="th_title">Length</td>
      <td class="th_title">Length</td>
    </tr>
    <tr>
      <td>36</td>
      <td>6</td>
      <td>4</td>
      <td>4.5</td>
      <td>36.5</td>
      <td>9.06</td>
      <td>23</td>
    </tr>
    <tr>
      <td>37</td>
      <td>6.5-7</td>
      <td>4.5-5</td>
      <td>5-5.5</td>
      <td>37.5</td>
      <td>9.25</td>
      <td>23.5</td>
    </tr>
    <tr>
      <td>38</td>
      <td>7.5</td>
      <td>5.5</td>
      <td>6</td>
      <td>38</td>
      <td>9.45</td>
      <td>24</td>
    </tr>
  </tbody>
</table>

 

Table表格滑过当前项[当前行][当前列]对应高亮的更多相关文章

  1. [转]CSS如何设置html table表格边框样式

    原文地址:http://www.divcss5.com/wenji/w503.shtml 对table设置css样式边框,分为几种情况: 1.只对table设置边框 2.对td设置边框 3.对tabl ...

  2. JS组件系列——Bootstrap Table 表格行拖拽(二:多行拖拽)

    前言:前天刚写了篇JS组件系列——Bootstrap Table 表格行拖拽,今天接到新的需要,需要在之前表格行拖拽的基础上能够同时拖拽选中的多行.博主用了半天时间研究了下,效果是出来了,但是感觉不尽 ...

  3. MiniUI动态添加table表格

    本文将介绍一下,如何用Jquery MiniUi动态添加一行table表格 1.效果展示 ↓ 2.具体代码 <script type="text/javascript"> ...

  4. table表格宽度固定,同时td内容过长也不会被撑开

    table表格宽度固定,同时td内容过长也不会被撑开,设置如下css: table{table-layout:fixed;word-break:break-all;}

  5. Bootstrap Table表格一直加载(load)不了数据-解决办法

    bootstrap-table是一个基于Bootstrap风格的强大的表格插件神器,官网:http://bootstrap-table.wenzhixin.net.cn/zh-cn/ 这里列出遇到的一 ...

  6. [js开源组件开发]table表格组件

    table表格组件 表格的渲染组件,demo请点击http://lovewebgames.com/jsmodule/table.html,git源码请点击https://github.com/tian ...

  7. jquery 生成table表格 部分代码

    想生成上面这样的table表格先看返回数据格式 <div id="create_img_tab"></div> window.onload = functi ...

  8. jquery隐藏table表格的某一列

    jquery隐藏table表格的某一列: $('table tr').find('td:eq(13)').hide(); 隐藏table的第13列

  9. asp.net将内容导出到Excel,Table表格数据(html)导出EXCEL

    代码: /// <summary> /// HTML Table表格数据(html)导出EXCEL /// </summary> /// <param name=&quo ...

随机推荐

  1. 使用vue-cli搭建项目开发环境

    一.前言 本篇文章主要是使用vue-cli搭建一个简单的vue项目,这个项目在其他文章中作为代码演示的环境会一直使用. 注意:默认大家的电脑已经安装nodejs,所以这里不总结nodejs的安装. 二 ...

  2. [java] 集合的架构——1张图表示

  3. Master原理

    1.主备切换机制原理剖析与源码分析 2.注册机制原理剖析与源码分析 3.状态改变处理机制源码分析 4.资源调度机制源码分析(schedule(),两种资源调度算法)(核心) 一.主备切换机制原理 1. ...

  4. 第一个Hadoop程序-单词计数

    上一篇配置了Hadoop,本文将测试一个Hadoop的小案例 hadoop的Wordcount程序是hadoop自带的一个小的案例,是一个简单的单词统计程序,可以在hadoop的解压包里找到,如下: ...

  5. Windows下搭建远程Linux主机的图形化本地开发环境

    在实际开发中,项目的类生产.生产环境一般都是选择Linux为服务器进行部署. 相应的,我们的开发最好也在Linux环境下进行,否则容易引发其他的问题,比如不同环境下功能不一致.库依赖差异等. 但是Li ...

  6. 力扣(LeetCode)整数反转 个人题解

    给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转. 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: ...

  7. 在VMware通过挂载系统光盘搭建本地yum仓库

    1.首先需要有一个VMware虚拟机: 2.进去虚拟机(这里用Linux下deCentOS进行演示): 3.用root账号进行登录,否则在根目录下没有一些操作权限: 4.打开终端: 5,输入命令“cd ...

  8. FIddler+Proxifer工具对windows PC客户端进行抓包

    python的大火,带动了python爬虫. 爬虫就必定绕不开抓包. 目前最常见的就是网页抓包了,可以使用chrome进行,或者配合其他抓包软件 fiddler. 小程序有些兴起是,如跳一跳之类的,也 ...

  9. Flex利用JavaScript执行cmd命令

    Flex: //注册js事件            protected function init():void            {                ExternalInterfa ...

  10. 【论文阅读】A practical algorithm for distributed clustering and outlier detection

    文章提出了一种分布式聚类的算法,这是第一个有理论保障的考虑离群点的分布式聚类算法(文章里自己说的).与之前的算法对比有以下四个优点: 1.耗时短O(max{k,logn}*n), 2.传递信息规模小: ...