鼠标移开后的边框

问题描述 投票:0回答:1

在鼠标悬停时在单元格中添加粉红色边框

 let TH = documenter code hereent.getElementsByTagName('th');
       for (i = 0; i < TH.length; i++) {
           TH[i].addEventListener('mouseover', function(e){
             if(e.target) {
              this.style.border = '5px solid pink';


             } else {
              this.style.border = 'none';
             }

            });
        }

当我将鼠标移出时,它仍然是相同的粉红色(边框)。如何解决?

javascript dom dom-manipulation
1个回答
0
投票
$( "td" ).hover(
    function() {
        $( this ).addClass( "hover" );
    }, function() {
        $( this ).removeClass( "hover" );
    }
);

//then you can add specific style for hover on a css file
© www.soinside.com 2019 - 2024. All rights reserved.