javascript - How can I Identify the DIv which got clicked in Jquery -
i need know click event happens in document, have divs , , when press cntrl key , click on them events occur, need know how identify divs got clicked, possible generalize them in document.click fn have tried. here sample of have tried
html
<div class="divone">div1</div> <div class="divtwo">div2</div> <div class="divthree">div3</div>
jquery
$(document).bind("click", function (e) { if (e.which == '17') { alert(e.parent);//i need know whether click happens on divone or 2 or on no mans land } });
you can use e.target
along .is()
function achieve want.
try,
$(document).bind("click", function (e) { if($(e.target).is('.divone')){ alert('div 1 has been clicked..!') } });
Comments
Post a Comment