当前位置:网站首页>微博发布案例
微博发布案例
2022-07-07 04:00:00 【九阈】
①点击发布按钮,动态创建一个小li ,放入文本框的内容和删除按钮,并且添加到ul中。
②点击的删除按钮,可以删除当前的微博留言。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
ul{
list-style: none;
}
.box {
position: relative;
width: 450px;
height: 450px;
margin: 20px auto;
background-color: skyblue;
}
button {
position: absolute;
right: 10px;
top: 50px;
width: 80px;
height: 80px;
border: 0;
font-size: 20px;
}
textarea {
outline: none;
}
li {
padding: 5px 0;
}
</style>
<script src="jquery.min.js"></script>
</head>
<body>
<div class="box" id="weibo">
<textarea name="" class="txt" id="" cols="40" rows="10"></textarea>
<button class="btn">发布</button>
<div>留言区:</div>
<ul></ul>
</div>
<script>
$(function(){
//1.点击发布按钮,动态创建一个小li,放入文本框的内容和删除按钮,并且添加到ul中
$(".btn").on("click",function(){
var li = $("<li></li>");
li.html($(".txt").val()+ "<a href='javascript:;'>删除</a>");
$("ul").prepend(li);
li.slideDown();
$(".txt").val("");
})
//2.点击的删除按钮,可以删除当前的微博留言li
$("ul").on("click","a",function(){
$(this).parent().slideUp(function(){
$(this).remove();
});
})
})
</script>
</body>
</html>
部分代码转载于
https://blog.csdn.net/weixin_58131487/article/details/120946647
边栏推荐
- Tumor immunotherapy research prosci Lag3 antibody solution
- idea添加类注释模板和方法模板
- Pass child component to parent component
- Cloud backup project
- Redis data migration
- MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
- 软件验收测试
- Composition API premise
- 1、 Go knowledge check and remedy + practical course notes youth training camp notes
- Bindingexception exception (error reporting) processing
猜你喜欢
Model application of time series analysis - stock price prediction
聊聊异步编程的 7 种实现方式
Sqlmap tutorial (IV) practical skills three: bypass the firewall
抽丝剥茧C语言(高阶)指针进阶练习
URP - shaders and materials - simple lit
Composition API premise
Apache AB stress test
【leetcode】1020. Number of enclaves
@component(““)
MobaXterm
随机推荐
Advanced level of C language (high level) pointer
点亮显示屏的几个重要步骤
resource 创建包方式
Music | cat and mouse -- classic not only plot
Modify the jupyter notebook file path
直播平台源码,可折叠式菜单栏
The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
二、并发、测试笔记 青训营笔记
C language (high-level) data storage + Practice
聊聊异步编程的 7 种实现方式
弹性布局(二)
English translation is too difficult? I wrote two translation scripts with crawler in a rage
KBU1510-ASEMI电源专用15A整流桥KBU1510
@component(““)
Redis data migration
Detailed explanation of neo4j installation process
計算機服務中缺失MySQL服務
Cloud backup project
My ideal software tester development status
[Linux] process control and parent-child processes