Check what element the cursor is on upon mouseleave() with jQuery?

前端 未结 2 1096
無奈伤痛
無奈伤痛 2021-01-07 16:42

I have a set of list elements (

  • within a
      ) laid out as bubbles on a chart like this, where the bubbles are the
  • 2条回答
    •  温柔的废话
      2021-01-07 17:44

      You need to use event.toElement || e.relatedTarget:

      $('li').mouseleave(function(e)
      {
          // new element is: e.toElement || e.relatedTarget
      });
      

      (Edited to note || e.relatedTarget to ensure browser compatibility)

    提交回复
    热议问题