I am creating an app using PhoneGap and I'm having trouble getting the selected id of a listview item when it is long pressed.

I have tried using the JQUeryMobile TapHold event which works but only gets the ID of the listview, not the individual items.

$('#listview').bind('taphold', '> li', function (event) {

I am dynamically creating the list using the code below:


<ul data-role="listview" id="listview">  </ul>


for(var i = 0; i<len; i++) {
    var output = '<li><h3> Module Code: ' + results.rows.item(i).module + '</h3>Room: ' +results.rows.item(i).room +'</li>';

Any help is appreciated, thanks!

Assuming that the $(this).index() is the ListView index, you could do something like:


Probably the ListView uses some css class to indicate which item is selected or not. I don't know which class it is, but it shouldn't be hard to figure it out.