sureshunivers
sureshunivers

Reputation: 1753

How to get target element on touch end event handler?

I have function touchstart, touchmove & touchend handler like bellow for an container, the container contains number of elements. In the touchmove handler I am drawing line in canvas.

function touchStartHandler(e){
   var elem = e.target;
   console.log($(elem).text());
}
function touchEndHandler(e){
   var elem = e.target;
   console.log($(elem).text());
}
function touchMoveHandler(e){
   //
}

I want to get the element in the touchend. The event's target is the same element that received the touchstart event. Any solution for this to get element in the touchend event?

Upvotes: 2

Views: 4431

Answers (1)

l0lander
l0lander

Reputation: 2153

Try with e.changedTouches.item(0)

function touchEndHandler(e){
   var elem = e.changedTouches.item(0) ;
   console.log($(elem).text());
}

Take a look at this question for more info: Find element finger is on during a touchend event

Upvotes: 1

Related Questions