//打开数据库
var dbSize=2*1024*1024;
db = openDatabase('firstDB', '', '', dbSize);
db.transaction(function(tx){
//创建数据表
tx.executeSql("CREATE TABLE IF NOT EXISTS customer (id integer PRIMARY KEY,name char
(10),address varchar(200))");
showAll();
});
$( "button" ).click(function () {
var name=$("#name").val();
var address=$("#address").val();
if(name=="" || address==""){
$("#message").html("**请输入姓名和地址**");
return false;
}
db.transaction(function(tx){
//新增数据
tx.executeSql("INSERT INTO customer(name,address) values(?,?)",
[name,address],function(tx, result){
$("#message").html("新增数据完成!")
showAll();
},function(e){
$("#message").html("新增数据错误:"+e.message)
});
});
})
$("#showData").on('click', ".delItem", function() {
var delid=$(this).prop("id");
db.transaction(function(tx){
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这后面可以随便修改