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</ ...
随机推荐
- lightoj--1043-- Triangle Partitioning (水题)
Triangle Partitioning Time Limit: 500MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu S ...
- 仿即刻app"猜你喜欢"切换控件
最近在即刻里看到即刻的"猜你喜欢"的板块,觉得效果很赞. 当点击"换一换"时,上面三个条目程序切换效果,并且三个条目的切换以不同的速度进行. 于是开始想办法撸出 ...
- 20.发送http请求服务 ($http)
转自:https://www.cnblogs.com/best/tag/Angular/ 服务从代码直接与服务器进行交互,底层是通过实现,与中http服务从AngularJS代码直接与Web服务器进行 ...
- 今日SGU 5.23
SGU 223 题意:给你n*n的矩形,放k个国王,每个国王不能放在别的国王的8连边上,问你有多少种方法 收获:状态DP,因为每行的放置只会影响下一行,然我们就枚举每行的状态和对应的下一行的状态,当两 ...
- Json学习总结(1)——Java和JavaScript中使用Json方法大全
摘要:JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的文本格式,但是也使用了类似于C语 ...
- CSUOJ 1638 Continued Fraction
1638: Continued Fraction Time Limit: 1 Sec Memory Limit: 128 MB Description Input Output Sample Inp ...
- [ES6] The Iterator Protocol
The iterator protocol is used to define a standard way that an object produces a sequence of values. ...
- 云计算时代告别phpMyAdmin
云计算时代告别phpMyAdmin phpMyAdmin是一款很经典的MySQL数据库管理工具,在云计算快速发展的今天,phpMyAdmin交互老旧.已经不能适应时代步伐.因此有很多人開始选择一些更高 ...
- OpenLayers3基础教程——OL3之Popup
概述: 本节重点讲述OpenLayers3中Popup的调用时实现,OL3改用Overlay取代OL2的Popup功能. 接口简单介绍: overlay跟ol.control.Control一样,是一 ...
- unity 获取物体尺寸
unity3d中获得物体的size 以size的x方向为例 1:gameObject.renderer.bounds.size.x;//这个值的结果真实反应出有MeshRenderer这个组件的 ...