Detect if mouse is above column border

Does anyone know how I can determine if the mouse is above the column border or cell border, or jQuery, or JavaScript?

I want to implement resizing a column in a specific table.

Any help is appreciated.

+3
source share
3 answers

You should check if the offset X and offsetY are less than the width of the border, and if you are on the border, also check if the offsetX value is greater than innerWidth or offsetY is greater than innerHeight

$('td').hover(function(e){
    var border_width = parseInt($(this).css('border-width'));
    if(e.offsetX < border_width || e.offsetX > $(this).innerWidth() || e.offsetY < border_width || e.offsetY > $(this).innerHeight()){
        console.log('This is the border');  
    }
});

Here jsFiddle

+6
source

Perhaps you can do the following:

  • Listening to a mouseover event on an item
  • .
  • () + outerWidth() , , .
+1

, , , , - , mousemove, clone . , , , . Booyah!

0

Source: https://habr.com/ru/post/1542729/


All Articles