Get ID of the element I hover over with jQuery?

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

I have a bunch of elements that look like this:

html
php         


        
4条回答
  •  旧时难觅i
    2020-12-06 05:13

    $('.tags').hover(
      function() { console.log( 'hovering on' , $(this).attr('id') ); },
      function() {}
    );
    

    Second empty function is for mouse out, you'll probably want to do something on that event as well.

提交回复
热议问题