maxum maxum - 1 year ago 88
jQuery Question

get ID of li when swiped

I have a list as follows.

<ul id="hook_list">
<li id="a1">one</li>
<li id="a2">two</li>
<li id="a3">three</li>
<li id="a4">four</li>

I am using
to detect swipe events ..

var myElement = document.getElementById('hook_list');
var mc = new Hammer(myElement);
mc.on("swipe", function(ev) {
alert('Detect swipe');

It detects the swipe no problem but I am not sure how to pull the
from the swiped
. I have tried
as I have jquery on the same page but I just get

How do I get the
from the swiped

Answer Source

Since you are binding the swipe event to the ul, you can't use this to get the id of the ul

However, since you have the reference to the event object in ev you can use the ev and use

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download