I have an element with event onMouseOver. I need to get the ID for the element when the event is fired.
Here my HTML structure:
'<div id="see_all" class="btn_backtostart_catview">' +
'<div class="btn_backtostart_slice_l_catview"></div>' +
'<div class="btn_backtostart_slice_c_catview" onclick="Main.magicCtrVerTodas()" onMouseOver="Main.magicCtrVerTodasMouseOver(this)">Ver todas</div>' +
'<div class="btn_backtostart_slice_r_catview"></div>' +
'</div>' +
The function
magicCtrVerTodasMouseOver: function(obj){
console.log('ID for elm in OVER: ' + obj);
},
As result I get HTMLDivElement no the name of the ID.
Any idea what I’m doing wrong? I also can use jQuery.
Variable
objis referred to<div>element with class"btn_backtostart_slice_c_catview". This element doesn’t have an ID attribute.If you need to get the
idproperty of the parent<div>(holdingid="see_all"), you may use: