当前位置:网站首页>微博发布案例
微博发布案例
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
边栏推荐
猜你喜欢
Mutual conversion between InputStream, int, shot, long and byte arrays
Non empty verification of collection in SQL
Music | cat and mouse -- classic not only plot
How to reduce inventory with high concurrency on the Internet
Project practice five fitting straight lines to obtain the center line
idea添加类注释模板和方法模板
MobaXterm
四、高性能 Go 语言发行版优化与落地实践 青训营笔记
[2022 ACTF]web题目复现
The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
随机推荐
I failed in the postgraduate entrance examination and couldn't get into the big factory. I feel like it's over
mips uclibc 交叉编译ffmpeg,支持 G711A 编解码
Sqlmap tutorial (IV) practical skills three: bypass the firewall
Invalid table alias or column reference`xxx`
我理想的软件测试人员发展状态
Chinese and English instructions prosci LAG-3 recombinant protein
After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
Outsourcing for four years, abandoned
"Xiaodeng in operation and maintenance" meets the compliance requirements of gdpr
Freeswitch dials extension number source code tracking
English translation is too difficult? I wrote two translation scripts with crawler in a rage
Explain Bleu in machine translation task in detail
Select the product attribute pop-up box to pop up the animation effect from the bottom
基于Flask搭建个人网站
身边35岁程序员如何建立起技术护城河?
1142_ SiCp learning notes_ Functions and processes created by functions_ Linear recursion and iteration
C language (high-level) data storage + Practice
The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
【leetcode】1020. Number of enclaves
IO流 file