<bdo id='6QBtr'></bdo><ul id='6QBtr'></ul>
<i id='6QBtr'><tr id='6QBtr'><dt id='6QBtr'><q id='6QBtr'><span id='6QBtr'><b id='6QBtr'><form id='6QBtr'><ins id='6QBtr'></ins><ul id='6QBtr'></ul><sub id='6QBtr'></sub></form><legend id='6QBtr'></legend><bdo id='6QBtr'><pre id='6QBtr'><center id='6QBtr'></center></pre></bdo></b><th id='6QBtr'></th></span></q></dt></tr></i><div id='6QBtr'><tfoot id='6QBtr'></tfoot><dl id='6QBtr'><fieldset id='6QBtr'></fieldset></dl></div>

<small id='6QBtr'></small><noframes id='6QBtr'>

<tfoot id='6QBtr'></tfoot>
<legend id='6QBtr'><style id='6QBtr'><dir id='6QBtr'><q id='6QBtr'></q></dir></style></legend>

        html表格如何通过更改悬停边框来突出显示列?

        时间:2023-11-29

          1. <legend id='Q32J7'><style id='Q32J7'><dir id='Q32J7'><q id='Q32J7'></q></dir></style></legend>
            • <bdo id='Q32J7'></bdo><ul id='Q32J7'></ul>

              <tfoot id='Q32J7'></tfoot>
                <tbody id='Q32J7'></tbody>

                  <small id='Q32J7'></small><noframes id='Q32J7'>

                • <i id='Q32J7'><tr id='Q32J7'><dt id='Q32J7'><q id='Q32J7'><span id='Q32J7'><b id='Q32J7'><form id='Q32J7'><ins id='Q32J7'></ins><ul id='Q32J7'></ul><sub id='Q32J7'></sub></form><legend id='Q32J7'></legend><bdo id='Q32J7'><pre id='Q32J7'><center id='Q32J7'></center></pre></bdo></b><th id='Q32J7'></th></span></q></dt></tr></i><div id='Q32J7'><tfoot id='Q32J7'></tfoot><dl id='Q32J7'><fieldset id='Q32J7'></fieldset></dl></div>

                • 本文介绍了html表格如何通过更改悬停边框来突出显示列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在探索如何设置表格样式,以便在鼠标悬停在列上时可以更改边框.

                  I'm exploring how to style a table in such a way that the border can be changed when the mouse hovers over a column.

                  当鼠标悬停在一列上时,我想通过更改边框颜色来突出显示该列:

                  When the mouse is over a column, I want to highlight that column by changing the border color:

                  为了突出显示,我在 jQuery 库中使用了以下 JavaScript 代码:

                  To highlight, I am using the following JavaScript code with the jQuery library:

                  $('td').hover(function() {
                      var t = parseInt($(this).index()) + 1;
                      $('td:nth-child(' + t + ')').addClass('highlighted');
                  },
                  function() {
                      var t = parseInt($(this).index()) + 1;
                      $('td:nth-child(' + t + ')').removeClass('highlighted');
                  });
                  

                  使用以下 CSS:

                  .highlighted {
                      border-top: 2px solid black;
                      border-right: 2px solid black;
                      border-left: 2px solid black;
                  }
                  

                  您可以在此 JSFiddle 中查看其工作原理:http://jsfiddle.net/sCFjj/1/这仅在我将鼠标悬停在最左侧的列上时才有效.否则,它会突出显示右列(和顶部),但不会突出显示左垂直列.有没有办法让左竖列出现?

                  You can view how this works in this JSFiddle: http://jsfiddle.net/sCFjj/1/ This is only working when I hover on the left-most column. Otherwise it highlights the right-column (and top) but not the left vertical column. Is there a way of making the left-vertical column appear?

                  理想情况下,我希望效果忽略最低行,但我不确定如何从 jQuery 选择中排除一行.

                  Ideally, I would like the effect to ignore the lowest row, but I am not sure how to exclude a row from the jQuery selection.

                  我的尝试基于之前的问题.

                  推荐答案

                  链接:jsFiddle.还添加到上一列border-right,你会得到你想要的.我认为该列的右边界在下一个列的左边界之上.

                  Link: jsFiddle. Also add to previous collumn border-right and you will get that you want. I think that collumn's right border is over next collumn left border.

                  JavaScript:

                  JavaScript:

                  $('td').hover(function() {
                      var t = parseInt($(this).index()) + 1;
                      $('td:nth-child(' + t + ')').addClass('highlighted');
                  
                      if(t>1){
                          var t1 = t -1;
                          //alert("T:" + t + "<br/> T1:" + t1);
                          $('td:nth-child(' + t1 + ')').addClass('highlightedPrev');
                      }
                  },
                  function() {
                      var t = parseInt($(this).index()) + 1;
                      $('td:nth-child(' + t + ')').removeClass('highlighted ');
                          if(t>1){
                           var t1 = t -1;
                           $('td:nth-child(' + t1 + ')').removeClass('highlightedPrev');
                      }
                  });
                  

                  CSS:

                  .highlighted {
                      border: 2px solid black;
                  }
                  .highlightedPrev {
                      border-right: 2px solid black;
                  }
                  

                  希望我解决了你的问题.

                  Hope I solved your problem.

                  这篇关于html表格如何通过更改悬停边框来突出显示列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:IE8 字体大小在 :hover 上切换 - 仅限日语语言 下一篇:如何通过孩子更改父样式:LESS中的悬停动作

                  相关文章

                    <bdo id='9Tvdq'></bdo><ul id='9Tvdq'></ul>
                • <small id='9Tvdq'></small><noframes id='9Tvdq'>

                    <legend id='9Tvdq'><style id='9Tvdq'><dir id='9Tvdq'><q id='9Tvdq'></q></dir></style></legend>

                    1. <i id='9Tvdq'><tr id='9Tvdq'><dt id='9Tvdq'><q id='9Tvdq'><span id='9Tvdq'><b id='9Tvdq'><form id='9Tvdq'><ins id='9Tvdq'></ins><ul id='9Tvdq'></ul><sub id='9Tvdq'></sub></form><legend id='9Tvdq'></legend><bdo id='9Tvdq'><pre id='9Tvdq'><center id='9Tvdq'></center></pre></bdo></b><th id='9Tvdq'></th></span></q></dt></tr></i><div id='9Tvdq'><tfoot id='9Tvdq'></tfoot><dl id='9Tvdq'><fieldset id='9Tvdq'></fieldset></dl></div>
                    2. <tfoot id='9Tvdq'></tfoot>