<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>websql应用</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<input type="text" id="title" />
<textarea name="context" id="context" cols="20" rows="8"></textarea>
<input type="button" value="保存" onclick="save()" />
<input type="button" value="查看" onclick="chakan()" />
<ol id="chakan">
123
</ol>
</body>
<script>
var dbsize=2*1024*1024;
db=openDatabase("todo","","",dbsize);
db.transaction(function(tx){
tx.executeSql("CREATE TABLE IF NOT EXISTS notes (id integer PRIMARY KEY,title char(50),inputMemo text,last_date datetime)");
}
);
function save(){
var title=$("#title").val();
var inputMemo=$("#context").val();
db.transaction(function(tx){
tx.executeSql("INSERT INTO notes (title,inputMemo,last_date) values(?,?,datetime('now','localtime'))",[title,inputMemo]);
});
}
function chakan(){
$("ol").empty();
var note="";
db.transaction(function(tx){
tx.executeSql("SELECT id,title,inputMemo,last_date FROM notes",[],function(tx,result){
if(result.rows.length>0){
for (var i = 0; i <result.rows.length; i++) {
var item=result.rows.item(i);
//console.log(item["inputMemo"]);
note+="<li>"+"<h3>"+item["title"]+"</h3><p>"+item["inputMemo"]+"</p></li>";
}
$("#chakan").append(note);
}}
);
});
}
</script>
</html>

最新文章

  1. 怎样实现了捕获应用中的日志在android开发中
  2. [moka同学笔记]yii2 activeForm 表单样式的修改(二)
  3. pjax 历史管理 jQuery.History.js
  4. [terry笔记]Flashback
  5. android.os.DeadObjectException memory near r0: 异常处理 Consumer closed input channel or an error occurred. events=0x9
  6. HTML+CSS+JS学习总结
  7. opencv开发的程序分发给客户时所需要的dll文件
  8. SQL导入
  9. 手机字段存储报错 :Warning Code : 1264 Out of range value for column &#39;buyer_tpl&#39; at row 1
  10. centos6 搭建hdwiki
  11. UE4中FString转UTF8及UTF8转FString
  12. 关于C#chart图表实现多条折线动态绑定数据的问题
  13. java反射取private字段
  14. ios12怎么投屏电脑 苹果手机怎么投
  15. React Native之FlatList的介绍与使用实例
  16. kalman filter卡尔曼滤波器- 数学推导和原理理解-----网上讲的比较好的kalman filter和整理、将预测值和观测值融和
  17. CSS----布局注意事项
  18. Link Cut Tree 总结
  19. CubieTruck入手第一天
  20. java克隆机制

热门文章

  1. Failed to configure a DataSource: &#39;url&#39; attribute is not specified and no embedded datasource could be configured.Reason: Failed to determine a suitable driver class
  2. Python数据结构和类型--解压序列赋值多个变量
  3. 洛谷 p1141 01迷宫题解
  4. PAT (Advanced Level) Practise - 1099. Build A Binary Search Tree (30)
  5. 用事件队列解决GUI的操作顺序问题(Qt中处理方法)
  6. Dubbo中的监控和管理
  7. Bootstrap 原始按钮
  8. C++系统学习之六:函数
  9. Ubuntu18.04 下联想电脑 无法连接WIFI问题解决
  10. Mac OSX: 有线共享WiFi