關於ToDolist 的增刪改查 用jQuery來實現
程式碼如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="js/jquery-1.11.0.js" ></script>
<title>todolist</title>
<style>
*{
margin: 0px;
padding: 0px;
}
ul li{
list-style: none;
}
a{
text-decoration: none;
color: #777;
}
i{
font-style: normal;
}
.contains{
width: 960px;
margin: 20px auto;
border: 2px solid #ddd;
padding: 30px;
}
.theme_color>h3{
font-family: STXingkai;
margin-bottom: 5px;
color: #81D8E6;
}
.btn_red{
width: 35px;
height: 35px;
background: #F52C2C;
border: none;
cursor: pointer;
}
.btn_green{
width: 35px;
height: 35px;
background:#3AB93A;
border: none;
cursor: pointer;
}
.btn_blue{
width: 35px;
height: 35px;
background: #81D8E6;
border: none;
cursor: pointer;
}
.btn_yello{
width: 35px;
height: 35px;
background: #E2E25F;
border: none;
cursor: pointer;
}
.time{
float: right;
}
.search{
margin-top: 10px;
}
.search input{
width: 666px;
height: 35px;
border-radius: 4px;
outline: none;
border: 1px solid #DDDDDD;
}
.search_btn{
width: 60px;
height: 38px;
background: deepskyblue;
outline: none;
border: none;
border-radius: 4px;
margin-left: 5px;
cursor: pointer;
}
.content{
margin-top: 15px;
}
.content span{
color: #D80707;
}
.content i{
color: #1A8A1A;
}
.content_con{
width: 930px;
height: 100px;
border: 1px solid #ddd;
padding: 10px;
margin-top: 10px;
border-radius: 4px;
}
.content_con1{
width: 930px;
height: 100px;
border: 1px solid #ddd;
padding: 10px;
margin-top: 10px;
border-radius: 4px;
}
.content_con_time{
float: left;
margin-top:30px;
}
.content_con_chk{
float: right;
margin-top:40px;
}
.content_con_chk a{
}
.footer{
margin-top: 20px;
color: #888;
}
.footer_time{
margin-top: 35px;
}
.modal{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
overflow: hidden;
/* -webkit-overflow-scrolling: touch;*/
outline: 0;
width: 600px;
margin: 0 auto;
top: 200px;
display: none;
}
.modal1{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
overflow: hidden;
/* -webkit-overflow-scrolling: touch;*/
outline: 0;
width: 600px;
margin: 0 auto;
top: 200px;
display: none;
}
.show {
display: block !important;
}
.modal-dialog{
position: relative;
width: auto;
margin: 10px;
}
.modal-content{
position: relative;
background-color: #fff;
/* -webkit-background-clip: padding-box;*/
background-clip: padding-box;
/*border: 1px solid #999;*/
border: 1px solid rgba(0, 0, 0, .2);
border-radius: 6px;
outline: 0;
/*-webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);*/
box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
}
.modal-header{
padding: 15px;
border-bottom: 1px solid #e5e5e5;
}
.modal-body {
position: relative;
padding: 15px;
}
.modal-footer{
padding: 15px;
text-align: right;
border-top: 1px solid #e5e5e5;
}
.modal_close{
background: none;
border: none;
color:rgba(153, 153, 153, 0.58);
font-weight: bolder;
float: right;
font-size: 16px;
cursor: pointer;
}
.modal-body_con{
float: left;
}
.modal-body_tex{
float: left;
margin-bottom: 10px;
}
.modal-footer{
clear: both;
}
textarea{
resize: none;
outline: none;
border:1px solid #DDDDDD;
border-radius: 4px;
}
.modal-footer_okbtn{
width: 58px;
height: 35px;
color: white;
background: darkcyan;
outline: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
.modal-footer_nobtn{
width: 58px;
height: 35px;
color: white;
background:#626D28;
outline: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
.modal-footer_okbtn1{
width: 58px;
height: 35px;
color: white;
background: darkcyan;
outline: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
.modal-footer_nobtn1{
width: 58px;
height: 35px;
color: white;
background:#626D28;
outline: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
.modal-body>h3{
color: darkred;
}
</style>
</head>
<body>
<div class="contains">
<div class="head">
<div class="time">
<span class="time_show">上午好!</span>
</div>
<div class="theme_color">
<h3>主題顏色選擇:</h3>
<p><button class="btn_red"> </button> <button class="btn_green"> </button> <button class="btn_blue"> </button> <button class="btn_yello"> </button></p>
</div>
</div>
<div class="search">
<div>
<input type="text" placeholder="請輸入你想要搜尋的內容..." class="search_inp" /><button class="search_btn">傳送</button>
</div>
</div>
<div class="content">
<span class="waits">代辦事項:<strong>4</strong></span>
<i class="fin"> 已辦事項:<strong>0</strong></i>
<div class="content_con">
<p class="content_con_con">今天天氣非常好,太陽也很暖和,我們去游泳吧!</p>
<p class="content_con_time">2018-05-28</p>
<p class="content_con_chk"> <a href="#">檢視</a><input type="checkbox" /> </p>
</div>
<div class="content_con">
<p class="content_con_con">等你吃飯!</p>
<p class="content_con_time">2018-05-28</p>
<p class="content_con_chk"> <a href="#">檢視</a><input type="checkbox" /> </p>
</div>
<div class="content_con">
<p class="content_con_con">等你下課,不愛我就拉倒!!!</p>
<p class="content_con_time">2018-05-28</p>
<p class="content_con_chk"> <a href="#">檢視</a><input type="checkbox" /> </p>
</div>
<div class="content_con">
<p class="content_con_con">等你睡覺覺!</p>
<p class="content_con_time">2018-05-28</p>
<p class="content_con_chk"> <a href="#">檢視</a><input type="checkbox" /> </p>
</div>
</div>
<div class="footer">
<h2>歷史記錄</h2>
<!--<div class="content_con1">
<p>今天天氣非常好,太陽也很暖和,我們去游泳吧!今天一起非常好,太陽也很暖和,我們去游泳吧!今天一起非常好,太陽也很暖和,我們去游泳吧!</p>
<p class="footer_time">完成時間:2018-05-28。 晚上好!</p>
</div>
<div class="content_con1">
<p>今天天氣非常好,太陽也很暖和,我們去游泳吧!今天一起非常好,太陽也很暖和,我們去游泳吧!今天一起非常好,太陽也很暖和,我們去游泳吧!</p>
<p class="footer_time">完成時間:2018-05-28。 晚上好!</p>
</div>-->
</div>
</div>
<!--檢視模態框begin-->
<div class="modal ">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="modal_close">X</button>
<h3>修改管理</h3>
</div>
<div class="modal-body">
<div class="modal-body_con">
<p>內容:</p>
</div>
<div class="modal-body_tex">
<textarea cols="65" rows="10"></textarea>
</div>
</div>
<div class="modal-footer">
<button class="modal-footer_okbtn">確定</button>
<button class="modal-footer_nobtn">取消</button>
</div>
</div>
</div>
</div>
<div class="aa"></div>
<!--檢視模態框end-->
<!--完成模態框begin-->
<div class="modal1 ">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="modal_close">X</button>
<h3>修改管理</h3>
</div>
<div class="modal-body">
<h3>你確定完成了嗎?</h3>
</div>
<div class="modal-footer">
<button class="modal-footer_okbtn1">確定</button>
<button class="modal-footer_nobtn1" >取消</button>
</div>
</div>
</div>
</div>
<!--完成模態框end-->
<script>
//檢視 模態框彈出
var _this1=null
$(document).on("click",".content_con_chk a",function(){
_this1 = $(this)
$(".modal").show(300)
var _con = $(this).parents(".content_con").find(".content_con_con").text()
//console.log()
$(".modal").find("textarea").val(_con)
})
//檢視確定
$(document).on("click",".modal-footer_okbtn",function(){
//alert(123)
var _this_val= $(".modal").find("textarea").val();
_this1.parents(".content_con").find(".content_con_con").text(_this_val)
$(this).parents(".modal").hide(300)
})
$(document).on("click",".modal_close",function(){
$(".modal").hide(300)
})
$(document).on("click",".modal-footer_nobtn",function(){
$(".modal").hide(300)
})
$(document).on("click",".modal-footer_nobtn1",function(){
$(".modal1").hide(300)
})
//單選框 模態框 彈出
var _this = null
$(document).on("click",".content_con_chk input",function(){
$(".modal1").show(300)
_this = $(this)
})
$(document).on("click",".modal_close",function(){
$(".modal1").hide(300)
})
$(document).on("click",".modal-footer_nobtn",function(){
$(".modal1").hide(300)
})
//點選改變字型顏色
$(document).on("click",".btn_red",function(){
$(".content_con").addClass().css("color","#F52C2C")
})
$(document).on("click",".btn_green",function(){
$(".content_con").addClass().css("color","#3AB93A")
})
$(document).on("click",".btn_blue",function(){
$(".content_con").addClass().css("color","#81D8E6")
})
$(document).on("click",".btn_yello",function(){
$(".content_con").addClass().css("color","#E2E25F")
})
/*時間自動走begin*/
function times(){
var date = new Date();
var years = date.getFullYear();
var months = date.getMonth()+1;
var dates = date.getDate();
var hours = date.getHours();
var mins = date.getMinutes();
var secs = date.getSeconds();
var weeks=date.getDay();
var times=years+'年'+months+'月'+dates+'日'+' '+hours+':'+mins+':'+secs+' '+'星期'+weeks;
return times
}
//時間插入
var a = times();
$(".time_show").html(a)
setInterval(function(){
var a = times();
$(".time_show").html(a)
},1000)
/*時間自動走end*/
//傳送
var wait = 4;
$(document).on("click",".search_btn",function(){
var _val = $(".search_inp").val();
if($(".search_inp").val().length==0){
alert("輸入不能為空")
}else{
var str='<div class="content_con"><p class="content_con_con">'+_val+'</p><p class="content_con_time">'+times()+'</p><p class="content_con_chk"> <a href="#">檢視</a> <input type="checkbox"</p></div>'
$(".content").append(str);
wait++
$(".waits strong").html(wait);
$(".search_inp").val("");
}
})
//完成確定
/*$(document).on("click",".modal-footer_okbtn1",function(){
var _val = _this.parents(".content_con").find(".content_con_con").text()
//console.log(_this.parents(".content_con").find("p:eq(0)").text())
var str = '<div class="content_con1"><p>'+_val+'</p><p class="footer_time">完成時間:'+times()+'</p></div>'
$(".footer").append(str)
$(this).parents(".modal1").hide()
_this.parents(".content_con").hide(500)
})*/
var fin=0;
$(document).on("click",".modal-footer_okbtn1",function(){
//alert(123)
var _val=_this.parents(".content_con").find(".content_con_con").text()
//console.log(_val)
var str='<div class="content_con1"><p>'+_val+'</p><p class="footer_time">完成時間:'+times()+'</p></div>'
$(".footer").append(str)
$(this).parents(".modal1").hide(300)
_this.parents(".content_con").hide(500)
wait--
$(".waits strong").html(wait);
fin++
$(".fin strong").html(fin)
})
</script>
</body>
</html>
效果展示:
相關文章
- jQuery實現購物車的增刪改查jQuery
- 運用layui實現增刪改查UI
- js實現表格的增刪改查JS
- 關於連線資料庫實現增刪改查並且網頁上表現出來資料庫網頁
- 關於mongodb資料庫的增刪改查MongoDB資料庫
- jquery基本操作增刪改查有哪些?jQuery
- Go實現對MySQL的增刪改查GoMySql
- Android 中關於增刪改查資料庫表實踐Android資料庫
- Java實現簡單的增刪改查操作Java
- 單連結串列實現增刪改查
- .NET使用P/Invoke來實現登錄檔的增、刪、改、查功能
- mybatis實現MySQL資料庫的增刪改查MyBatisMySql資料庫
- 增刪改查
- Node.js+Express+Mysql 實現增刪改查Node.jsExpressMySql
- Mybatis-plus實現簡單增刪改查MyBatis
- Entity Framework使用DBContext實現增刪改查示例FrameworkContext
- 封裝模組實現商品增刪改查封裝
- 列表的增刪改查
- 字典的增刪改查
- layui的增刪改查UI
- mybatis的增刪改查MyBatis
- redist的增刪改查Redis
- Node+Vue實現對資料的增刪改查Vue
- 寫一個簡單的Linkedlist,實現增刪改查
- 使用Mongoose類庫實現簡單的增刪改查Go
- 用thinkphp進行增刪改查的操作PHP
- Python Web實戰:Python+Django+MySQL實現基於Web版的增刪改查PythonWebDjangoMySql
- webpack4+express+mongodb+vue 實現增刪改查WebExpressMongoDBVue
- JDBC連線mysql-8.0實現增刪改查JDBCMySql
- python 連線mongodb實現增刪改查例項PythonMongoDB
- SpringMVC+Spring Data JPA實現增刪改查操作SpringMVC
- 第一個mybatis程式,實現增刪改查CRUDMyBatis
- 連線資料庫並實現增、刪、改、查資料庫
- JDBC連線資料庫實現增刪改查JDBC資料庫
- koa+mysql實現增刪改查-全棧之路MySql全棧
- IDEA SpringBoot-Mybatis-plus 實現增刪改查(CRUD)IdeaSpring BootMyBatis
- SQL增刪改查SQL
- Mongoose查增改刪Go