Get ID of the element I hover over with jQuery?

后端 未结 4 1827
北海茫月
北海茫月 2020-12-06 04:22

I have a bunch of elements that look like this:

html
php         


        
4条回答
  •  -上瘾入骨i
    2020-12-06 05:05

    These solutions still returned an empty alert for me. For me, following worked when I handled the event object passed to the hover function:

    $(".input-box").hover(function(eventObj) { 
        alert(eventObj.target.id);  
    });
    

    Source of this solution

提交回复
热议问题