<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>Insert title here</title><script src="js/jquery-3.2.1.min.js"></script><script type="text/javascript"> //创建数据库:数据库名称,版本,表明,大小 var db=openDatabase("myDB","1.0","test db",2014*10); function Add(){ db.transaction(function(fx){ fx.executeSql("create table if not exists UserInfor(UserName TEXT,Pwd TEXT)",[]); //获取 var username=$("#txtAUserName").val(); var pwd=$("#txtAPwd").val(); fx.executeSql("insert into UserInfor values(?,?)",[username,pwd],function(){ alert("添加成功"); }); }); }</script></head><body><div><input type="text" id="txtAUserName"/> <input type="password" id="txtAPwd"/> <input type="button" value="添加" οnclick="Add();"/> </div></body></html>