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 ...
随机推荐
- Python基础-用户验证
一.项目需求 1.根据用户名和密码,验证用户是否可登陆 2.允许一次执行可验证三次 3.当用户名输错三次后,该用户名锁定,永久不可登陆 二.代码如下 #!/usr/bin/env python #-* ...
- SQLContext、HiveContext自定义函数注册
本文简单介绍两种往SQLContext.HiveContext中注册自定义函数方法. 下边以sqlContext为例,在spark-shell下操作示例: scala> sc res5: org ...
- spark算子:combineByKey
假设我们有一组个人信息,我们针对人的性别进行分组统计,并进行统计每个分组中的记录数. scala> val people = List(("male", "Mobi ...
- Spring Cloud学习笔记-001
Spring Boot快速入门 1. Eclipse新建maven工程,骨架选择quickstart: 2. 加入springboot的父工程,和web依赖: 3. 编写一个简单的RESTful接口, ...
- IIS7 http自动跳转到https
1.下载安装URL重写模块:Microsoft URL Rewrite Module 32位:http://download.microsoft.com/download/4/9/C/49CD28DB ...
- 使用poi根据模版生成word文档,支持插入数据和图片
一.制作word模版,${xxxx}是一会要替换的内容,最下面的表格是要插入数据,根据是否以$开头来判断是需要替换还是插入数据, 注意如果是需要插入数据,制作的表格模版需要一行空行,也只能有一行空行, ...
- 0308-标签的用法(a,ul/ol,table)
标签分为: 一般标签:<div> <span> <br/> <hr/> 功能标签:<a> <img> 实体标签:≶ > s ...
- 认识JQuery,JQuery的优势、语法、多库冲突、JS原生对象和JQuery对象之间相互转换和DOM操作,常用的方法
(一)认识JQuery JQuery是一个JavaScript库,它通过封装原生的JavaScript函数得到一套定义好的方法 JQuery的主旨:以更少的代码,实现更多的功能 (二)JQue ...
- python 虚拟环境的搭建
1.python3.6 2.MySQL 3.安装虚拟环境 1.pip install virtualenv -i https://pypi.douban.com/simple/ 2.pip ins ...
- Struts2--二次提交
在Struts2中,使用token的方式来防止二次提交.并且在默认的拦截器栈中提供了两个默认拦截器Token Interceptor和Token Session Interceptor.必须要在for ...