jquery - How can I get the id of div which is currently being hovered? -


suppose have multiple div same class different id. how can id of div being hovered user.

<div class='same_class' id='differnt_id_1'></div> <div class='same_class' id='differnt_id_2'></div> <div class='same_class' id='differnt_id_3'></div> <div class='same_class' id='differnt_id_4'></div> 

let user hover div having id different_id_1 yet don't know id of element, know user has hovered element. how can id of hovered element using jquery. in advance.

you can user this reference inside hover event handler.

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

$(this) inside event handler element on event occured.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -