JS / CSS 实现的便签记录本
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js实现便签</title>
<style>
.labelstart{
background:red;
text-align:center;
margin:50px 50px 0px 50px;
padding:30px;
}
input{
width:400px;
height:25px;
box-shadow: 3px 4px 5px grey;
border-radius:5px;
}
.btn{
cursor: pointer;
height:30px;
border-radius:5px;
width:50px;
box-shadow: 3px 4px 5px grey;
}
#mytab{ background:grey;
margin:0px 50px 50px 50px;
padding:30px;
}
#mytab li{
border-bottom:1px solid black;
height:30px;
cursor: pointer;
padding:10px
}
#mytab li:nth-child(odd) {
background: lightgrey;
}
span{
float:right;
font-size:16px;
padding:10px }
span:hover{
color:red;
cursor: pointer;
}
ol li.checked {
background: #888;
color: #fff;
text-decoration: line-through;
} ol li.checked::before {
content: '';
position: absolute;
border-color: #fff;
border-style: solid;
border-width: 0 2px 2px 0;
top: 10px;
left: 16px;
transform: rotate(45deg);
height: 15px;
width: 7px;
} </style>
</head>
<body>
<div class="labelstart">
<h3>
请输入要办的事项
</h3>
<input type="text" id="myInput" >
<button type="button" class="btn" onclick="add()">
添加
</button> </div>
<Ol id="mytab">
<li class="content">HTML<span class="close">×</span></li>
<li class="content">CSS<span class="close">×</span></li>
<li class="content">JS <span class="close">×</span></li>
<li class="content">NODE.JS <span class="close">×</span></li>
</Ol> <script> //添加标签 function add(){
//创建一个li标签
var getli=document.createElement("li");
//给li加入class
getli.className="content";
//创建span
var getspan=document.createElement("span"); var getclose=document.createTextNode("\u00D7");
//获得input的内容
var getinput=document.getElementById("myInput").value;
var getcontent=document.createTextNode(getinput);
//按顺序添加子节点
getspan.className="close";
getspan.appendChild(getclose);
getli.appendChild(getcontent);
getli.appendChild(getspan)
var getol=document.getElementById("mytab");
getol.appendChild(getli)
//并且给这里的函数绑定删除事件
getspan.onclick=function(){
this.parentElement.style.display = "none";
}
} //给原来的标签注册删去标签事件 var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
this.parentElement.style.display = "none"; }
}
//当点击li标签时添加中划线
var list=document.getElementById("mytab");
list.addEventListener('click', function(ev) {
if (ev.target.tagName === 'LI') {
ev.target.classList.toggle('checked');
}
}, false); </script>
</body>
</html>
JS / CSS 实现的便签记录本的更多相关文章
- CSS3+JS 实现的便签应用
概述 利用HTML5新增的 locationStorage 实现的便签应用,没有使用 JQuery,主要是为了练习原生JS的使用,采用响应式开发,在手机端和桌面端都有良好的体验,而且使用CSS3添加了 ...
- js便签笔记(12)——浏览TOM大叔博客的学习笔记 part2
1. 前言 昨天写了<js便签笔记(11)——浏览TOM大叔博客的学习笔记 part1>,简单记录了几个问题.part1的重点还是在于最后那个循环创建函数的问题,也就是多个子函数公用一个闭 ...
- js便签笔记(2)——DOM元素的特性(Attribute)和属性(Property)
1.介绍: 上篇js便签笔记http://www.cnblogs.com/wangfupeng1988/p/3626300.html最后提到了dom元素的Attribute和Property,本文简单 ...
- ios UIWebView截获html并修改便签内容(转载)
ios UIWebView截获html并修改便签内容 博客分类: iphone开发iphone开发phoneGap uiwebviewstringByEvaluatingJavaScriptFromS ...
- ASP.NET MVC 4 RC的JS/CSS打包压缩功能 Scripts.Render和Styles.Render
打包(Bundling)及压缩(Minification)指的是将多个js文件或css文件打包成单一文件并压缩的做法,如此可减少浏览器需下载多个文件案才能完成网页显示的延迟感,同时通过移除JS/CSS ...
- 20151217JS便签
JS便签: 根据一个数值来改变Repeater行数的颜色 <script type="text/javascript"> var query = document.ge ...
- ASP.NET MVC 4 RC的JS/CSS打包压缩功能 (转载)
ASP.NET MVC 4 RC的JS/CSS打包压缩功能 打包(Bundling)及压缩(Minification)指的是将多个js文件或css文件打包成单一文件并压缩的做法,如此可减少浏览器需下载 ...
- 史上前端面试最全知识点(附答案)---html & js & css
史上前端面试最全知识点(附答案) 一.html & js & css 1.AMD和CMD是什么?它们的区别有哪些? AMD和CMD是二种模块定义规范.现在都使用模块化编程,AMD,异步 ...
- maven压缩js css
maven压缩<plugin> <!-- YUI Compressor Maven压缩插件 --> <groupId>net.alchim31.maven</ ...
随机推荐
- java调用com组件将office文件转换成pdf
在非常多企业级应用中都涉及到将office图片转换成pdf进行保存或者公布的场景,由于pdf格式的文档方便进行加密和权限控制(类似于百度文库).总结起来眼下将office文件转换 成pdf的方法主要有 ...
- ubuntu 下安装eclipse &java环境配置
前面有一篇的博客写的是ubuntu下安装eclipse和java环境的配置.当时是安装网上的攻略进行的 ,当然也是能够成功的. 近期把那台电脑送人了 ,仅仅好在自己的这台电脑上又一次安装一次了 ,唯一 ...
- Nios II 系统时钟timestamp的应用
在用Nios II做外设时序驱动的时候,经常会用延时函数.有时会常使用某个FPGA芯片和时钟,比如笔者一直使用的芯片是cyclone系列 EP2C35F484C8N,PLL输入SOPC时钟是50M.因 ...
- win7防火墙里开启端口的图文教程
转载于:http://www.cnblogs.com/vipsoft/archive/2012/05/02/2478847.html 开启端口:打开“控制面板”中的“Windows防火墙”,点击左侧的 ...
- Swift学习笔记(12)--数组和字典的复制
Swift中,数组Array和字典Dictionary是用结构来实现的,但是数组与字典和其它结构在进行赋值或者作为参数传递给函数的时候有一些不同. 并且数组和字典的这些操作,又与Foundation中 ...
- UVALive 6869 Repeated Substrings
Repeated Substrings Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Descri ...
- 图解hdu5301Buildings
这个题就是给出一个大矩形n*m.当中有个1*1的小格子不能被占用,然后要你用非常多小矩形去填满.问小矩形的最小最大面积是多少. 显然小矩形必定是1*x的最好,毕竟i*x,若i>1则还是能够拆成非 ...
- OSX: 禁止iCloud钥匙链?
自从10.9有了一个新的功能叫viewlocale=zh_CN">iCloud钥匙串的,就出现了不少的麻烦.一是在10.9.3之前.好多人出现无限循环地要求用户输入Local item ...
- 1.实用:Google Chrome 键盘快捷键大全
转自:https://www.cnbeta.com/articles/soft/64070.htm 窗口和标签页快捷方式 Ctrl+N 打开新窗口 按住 Ctrl 键,然后点击链接 在新标签页中打开 ...
- POJ 3051 DFS
题意:判断连通块大小 水题 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm ...