Obtenir une position "top" absolue à partir d'un événement de souris (Javascript / jQuery)

StackOverflow https://stackoverflow.com/questions/1045398

  •  20-08-2019
  •  | 
  •  

Question

Lors d'un événement mouseenter / mouseleave, je voudrais capturer la position absolue "en haut" de la cellule d'un tableau.

Jusqu'à présent, l'événement est attaché comme suit:

$('td[someAttr]').mouseenter(function(mouse) {
   // how do we get the td's top absolute position?

   //FYI: mouse.pageX and mouse.pageY would give the mouse position
});
Était-ce utile?

La solution

$(this).offset().top
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top