views:

13

answers:

2

Hii,

I have an issue of using event.srcElement that i have write an event handler for a class selector but when i am taking the source element the exact element which i have clicked is not getting.Is there any alternative there

+1  A: 

Use

e.target instead

$("#btn").click(function(e){
   // The following will get you the DOM element that initiated the event.
   var targetELement = e.target; 
});
rahul
A: 

Try:

var target = e.target || e.srcElement;

but when i am taking the source element the exact element which i have clicked is not getting.Is there any alternative there

You mean this:

$('#element_id').click(function(){
  $(this).... // it refers to current element
});

If you want to get element in to be used in plain javascript, you can do like:

$('#element_id').get(0);
Sarfraz