1

我创建了一个应用程序,当长按按钮时,它会显示一个带有消息的确认框。如果用户选择ok,则执行任务;否则它什么也不做。

所以我已经编写了代码,但是当我在模拟器上运行它时,它什么也没做。这是代码:

$(document).ready(function(){
    $("#tapholder").bind("tapholder",function(){
        var hi=confirm("Do you really want to delete data");
        if(hi==true) {
            db.transaction(function(tx){
                tx.executeSql(deleterecord,[id]);
                alert("Record Deleted Successfully");
                parent.location='file:///android_asset/www/index.html';
            });
        }else{
            alert("Data not deleted");
        }
    });
});

<td id="Cancel"><button id="tapholder">DeleteRecord</button></td>
4

1 回答 1

1

Tapholder 事件不存在,它应该是taphold并且您还应该将它绑定一点点不同,而不是 bind 您应该使用函数on

$(document).on("taphold","#tapholder",function(){
    var hi=confirm("Do you really want to delete data");
    if(hi==true){
        db.transaction(function(tx){
            tx.executeSql(deleterecord,[id]);
            alert("Record Deleted Successfully");
            parent.location='file:///android_asset/www/index.html';
        });
    }else{
        alert("Data not deleted");
    }
});
于 2013-06-07T07:00:53.140 回答