码迷,mamicode.com
首页 > 其他好文 > 详细

localStorage_留言板(储存功能)

时间:2017-05-09 21:40:38      阅读:310      评论:0      收藏:0      [点我收藏+]

标签:cli   tle   bsp   pos   images   har   doc   ora   head   

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>留言本</title>
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    $(function(){
        //本地留言板内容不为空
        if(localStorage.getItem("k_con")!=null){
            "k_con",$("#dCon").html(localStorage.getItem("k_con"));
        }
    });
    function PostClick(){
        var trCon=$("#trCon").val();
        //将获取的内容直接加到 给定的div中
        $("#dCon").append("<div>"+trCon+"</div>");
        //将留言板内容存入本地
        localStorage.setItem("k_con",$("#dCon").html());
    }
</script>

</head>
<body>
    <div><textarea id="trCon" cols="30" rows="8"></textarea></div>
    <div><input type="button" value="发表" onclick="PostClick();"> <input type="button" value="清除"> </div>
    <div id="dCon"></div>
</body>
</html>

技术分享

 

localStorage_留言板(储存功能)

标签:cli   tle   bsp   pos   images   har   doc   ora   head   

原文地址:http://www.cnblogs.com/gf36500/p/6832611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!