首页 > 技术文章 > 留言板

gf36500 2017-05-17 17:14 原文

<!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">
    //页面打开之后
    $(function(){
        if(localStorage.getItem("k_con")!=null){
            "k_con",$("#dCon").html(localStorage.getItem("k_con"));
        }
    });

    function PostCon(){
        var sCon=$("#trCon").val();

        $("#dCon").append("<div>"+sCon+"</div>");
        localStorage.setItem("k_con",$("#dCon").html());
    }
    
    function Clear(){
        $("dCon").html("");
        localStorage.clear();
    }
    
</script>
</head>
<body>
    <div><textarea id="trCon" rows="10" cols="30"></textarea></div>
    <div><input type="button" value="发表" onclick="PostCon();">
    <input type="button" value="清除" onclick="Clear();"/></div>
    <div id="dCon"></div>
</body>
</html>

推荐阅读