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</ ...
随机推荐
- 软件project总结
软件project的文档完结了.在这里面学到了好多东西.也通过它分析了对机房收费系统进行了更加具体的分析.尽管早就明确了之间的联系,可是越温习越体会到逻辑的重要性和全心全意为人民服务的精神. 这些文档 ...
- android 推断是否支持闪光灯
近期在做录制视频功能,在找一些资料时发现 要推断是否支持闪关灯,在这记录下来,怕以后忘记 public static boolean isSupportCameraLedFlash(PackageMa ...
- 前端编程提高之旅(十二)----position置入值应用
这次内推项目用到的遮罩及其页面下方button都涉及一个概念position置入值得概念.效果图例如以下: 一个元素position属性不是默认值static.那么该元素被称为定位元素. 定位的元素生 ...
- Protocol Buffers的基础说明和使用
我们開始须要使用protobuf的原因是,在处理OJ的contest模块的时候,碰到一个问题就是生成contestRank的时候.须要存储非常多信息. 假设我们採用model存储的话,那么一方面兴许假 ...
- java线程深入学习
一.java中的线程是通过Thread类创建的, //下面是构造函数,一个共同的特点就是:都是调用init()进行创建的 public Thread() { init(null, null, &quo ...
- Vue或React多页应用脚手架
https://github.com/zhujiasheng/vue-multipage https://github.com/MeCKodo/vue-multipage
- refresh table tablename ;MSCK REPAIR TABLE table_name;
在更改分区内的文件后刷新表 refresh table tablename ; 我们平时通常是通过alter table add partition方式增加Hive的分区的,但有时候会通过HDFS p ...
- Beautiful Soup的使用
Beautiful Soup简单实用,功能也算比较全,之前下载都是自己使用xpath去获取信息,以后简单的解析可以用这个,方便省事. Beautiful Soup 是用 Python 写的一个 HTM ...
- BZOJ——T 3732: Network
http://www.lydsy.com/JudgeOnline/problem.php?id=3732 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: ...
- Struts2的token标签
“token标签的实现原理是在表单中增加一个隐藏域,每次加载该页面时,该隐藏域的值都不相同.而TokenInterceptor拦截器则拦截所有用户请求,如果两次请求时该token对应隐藏域的值相同(前 ...