js简单备忘录
<section class="myMemory">
<h3 class="f-tit">记事本</h3>
<div class="myform">
<div class="formcon">
<p>标题:</p>
<input id="formTit" type="text"/>
<p>日期:</p>
<input id="formDate" type="date"/>
<p>内容:</p>
<textarea id="formCon" cols="30" rows="5"></textarea>
<button class="addBtn">添加事件<span class="add-success">添加成功</span></button>
<p>已添加提醒事件</p>
<div class="conbox">
<div class="thing">
<div class="th-head">
<h3 class="th-tit fl"></h3>
<div class="th-time fl"></div>
<span class="th-del">删除</span>
</div>
<div class="th-con">
<span class="con-list"></span>
</div>
</div>
</div>
</div>
</div>
</section>
/*记事本*/
.myform{
width:400px;
height:400px;
border:1px solid #fff;
margin:0 auto;
overflow:hidden;
background:#fff;
border-radius:20px;
}
.myMemory{
z-index:1000;
}
.f-tit{
color:#fff;
font-size:30px;
margin-left:45.5%;
margin-top:70px;
margin-bottom:30px;
}
.formcon{
width:100%;
height:100%;
overflow:auto;
overflow-x:hidden;
}
.myform p{
text-align:center;
font-size:20px;
padding-top:5px;
}
.myform input{
display:block;
font-size:20px;
text-align:center;
width:80%;
height:50px;
line-height:50px;
margin:0 auto;
border:1px solid #d4d4d4;
border-radius: 50px;
}
#formDate{
padding:10px 0 10px 50px;
}
#formCon{
display:block;
width:80%;
border-radius:20px;
margin:0 auto;
outline:none;
padding:6px 12px;
font-size:20px;
}
.addBtn{
display:block;
width:80%;
height:50px;
background:#E91E63;
border-radius:50px;
cursor:pointer;
margin:20px auto;
font-size:20px;
color:#fff;
position:relative;
}
.add-success{
width:50%;
position:absolute;
display:block;
height:30px;
background:#333;
top:-30px;
font-size:16px;
font-family:"微软雅黑";
text-align:center;
line-height:30px;
opacity:0.6;
filter:alpha(opacity=60);
border-radius:5px;
left:24%;
display:none;
}
.add-suc{
display:block;
}
.addBtn:hover{
background:#E90B50;
}
.formcon .conbox{
width:80%;
min-height:50px;
border-radius:20px;
border:1px solid #d4d4d4;
margin:0 auto;
padding:6px 12px;
}
.formcon .conbox .thing{
width:100%;
border-bottom:1px solid #d4d4d4;
display:none;
}
.formcon .conbox .th-head{
width:100%;
height:25px;
line-height:25px;
border-bottom:1px dashed #d4d4d4;
}
.th-tit{
float:left;
font-size:16px;
width:55%;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.th-time{
margin-left:30px;
font-size:12px;
}
.th-del{
float:right;
font-size:12px;
color:#777;
cursor:pointer;
text-decoration:line-through;
}
.myform .conbox .th-con{
width:100%;
padding:5px;
line-height:1.5;
font-family:"微软雅黑";
text-indent:1.3em;
font-size:14px;
}
.myform .conbox .th-con .con-list{
white-space:pre-wrap;
}
//记事本
var mesArr = localStorage.message?JSON.parse(localStorage.message) : [];
if(mesArr.length){
$(mesArr).each(function(){
var $thing = $(".thing").eq(0).clone().show();//克隆装事件的容器
$thing.find(".th-tit").html(this.title);
$thing.find(".th-time").html(this.times);
$thing.find(".th-con .con-list").html(this.fCon);
$thing.appendTo($(".conbox"));
})
}
//添加事件
$(".addBtn").click(function(){
if($("#formTit").val() && $("#formDate").val() && $("#formCon").val()){
var title = $("#formTit").val();
var times = $("#formDate").val();
var fCon = $("#formCon").val();
var $thing = $(".thing").eq(0).clone().show();
$thing.find(".th-tit").html(title);
$thing.find(".th-time").html(times);
$thing.find(".th-con .con-list").html(fCon);
$thing.appendTo($(".conbox"));
var obj = {};
obj.title = title;
obj.times = times;
obj.fCon = fCon;
mesArr.push(obj);
localStorage.message = JSON.stringify(mesArr);
$("#formTit").val("");//添加完清空输入内容
$("#formDate").val("");
$("#formCon").val("");
$(".add-success").html("添加成功").addClass("add-suc").addClass("animated fadeInUp");
setTimeout(function(){
$(".add-success").removeClass("animated fadeInUp").removeClass("add-suc")
},1400)
}
else{
$(".add-success").html("请填写完内容").addClass("add-suc").addClass("animated fadeInUp");
setTimeout(function(){
$(".add-success").removeClass("animated fadeInUp").removeClass("add-suc")
},1400)
}
})
//删除事件
$(".conbox").delegate(".th-del","click",function(){
var index = $(this).parents(".thing").index() - 1;
$(this).parents(".thing").remove();
mesArr.splice(index,1);
localStorage.message = JSON.stringify(mesArr);
})
js简单备忘录的更多相关文章
- js简单 图片版时钟,带翻转效果
js简单 图片版时钟,带翻转效果 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"& ...
- js简单操作Cookie
贴一段js简单操作Cookie的代码: //获取指定名称的cookie的值 function getCookie(objName) { var arrStr = document.cookie.spl ...
- js简单弹出层、遮罩层
<html> <head> <title>js简单弹出层</title> <style> /*阴影边框效果*/ .box-shadow-1 ...
- Tourist.js – 简单灵活的操作指南和导航插件
Tourist.js 是一个基于 Backbone 和 jQuery 开发的轻量库,帮助你在应用程序创建简单易用的操作指南和导航功能.相比网站,它更适合用于复杂的,单页网站类型的应用程序.Touris ...
- js简单显示和隐藏div,触发超链接,动态更改button值,setInterval()简单使用,jquery easyui弹出框简单使用 .
js简单显示和隐藏div .<!DOCTYPE html> .<html> .<head> .<meta charset="UTF-8"& ...
- Gulp.js - 简单、直观的自动化项目构建工具
Gulp.js 是一个简单.直观的构建系统.崇尚代码优于配置,使复杂的任务更好管理.通过结合 NodeJS 的数据流的能力,你能够快速构建.通过简单的 API 接口,只需几步就能搭建起自己的自动化项目 ...
- Node.js简单介绍并实现一个简单的Web MVC框架
编号:1018时间:2016年6月13日16:06:41功能:Node.js简单介绍并实现一个简单的Web MVC框架URL :https://cnodejs.org/topic/4f16442cca ...
- JS简单入门教程
JS简单教程 使用方法:放到任意html页面的head标签下 Test1方法弹出当前时间对话框 Test2方法for循环输出 Test3方法for(…in…)输出数组内容 <script typ ...
- js简单实现链式调用
链式调用实现原理:对象中的方法执行后返回对象自身即可以实现链式操作.说白了就是每一次调用方法返回的是同一个对象才可以链式调用. js简单实现链式调用demo Object.prototype.show ...
随机推荐
- Server.MapPath找不到命名空间,解决办法
最近在做微信公众号开发,在网上找了个例子实现获取Access_token的值,需要读取xml文件,结果就遇到这个问题
- jprofiler配置
cataline.sh JAVA_OPTS="$JAVA_OPTS -agentlib:jprofilerti=port=8849"JAVA_OPTS="$JAVA_OP ...
- JS笔记(一)
第一章: 编写JS流程: 1. 布局:HTML和CSS 2. 样式:修改页面元素样式,div的display样式 3. 事件:确定用户做什么操作,onclick(鼠标点击事件).onmouseo ...
- [SHOI2009] 会场预约 - Treap
Description PP大厦有一间空的礼堂,可以为企业或者单位提供会议场地.这些会议中的大多数都需要连续几天的时间(个别的可能只需要一天),不过场地只有一个,所以不同的会议的时间申请不能够冲突.也 ...
- python Flask
python Flask Flask是一个基于Python开发并且依赖jinja2模板和Werkzeug WSGI服务的一个微型框架,对于Werkzeug本质是Socket服务端,其用于接收http请 ...
- 前端学习之jquery/下
前端学习之jquery 一 属性操作 html(): console.log($("div").html()); $(".test").html("& ...
- pyspider爬取TripAdvisor
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Created on 2017-06-11 10:10:53 # Project: london f ...
- Angular筛选功能
业务场景:依据级别(level )和主题(Subtype )向后台传参数,进行筛选向前台返回数据列表. 代码如下:其中filterChoose()用于弹出筛选下拉框,filterButton()用于选 ...
- eclipse 复制原项目工作空间
eclipse 复制原项目工作空间 具体步骤: 1.首先把你需要升级的eclipse 下载并解压 2.解压好后,右击 3.进入后你能看到这样一个页面 4.我的安装路径D:\work\Eclipse\ ...
- 招募:Wiki 文档翻译小伙伴招募
https://github.com/dotnetcore/CAP/issues/93 为了推进 CAP 的国际化工作,为全球其他 .NET 开发者提供更加良好的文档阅读体验,现在需要对CAP wik ...