Get ID of the element I hover over with jQuery?

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

I have a bunch of elements that look like this:

html
php         


        
4条回答
  •  余生分开走
    2020-12-06 05:27

    mouseover should do the trick.

    $('.tags').mouseover(function() {
       alert(this.id);
    });
    

    Note that if you want to know when the mouse leaves as well, you can use hover.

提交回复
热议问题