当前位置:网站首页>微博发布案例
微博发布案例
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
边栏推荐
- At the age of 20, I got the ByteDance offer on four sides, and I still can't believe it
- 4、 High performance go language release optimization and landing practice youth training camp notes
- Role of virtual machine
- Flexible layout (I)
- I failed in the postgraduate entrance examination and couldn't get into the big factory. I feel like it's over
- Blue Bridge Cup Netizen age (violence)
- Advanced level of C language (high level) pointer
- Redis data migration
- How can a 35 year old programmer build a technological moat?
- 普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
猜你喜欢

Composition API premise

MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding

Non empty verification of collection in SQL

【leetcode】1020. Number of enclaves

Redis data migration

Flexible layout (I)
![[2022 CISCN]初赛 web题目复现](/img/1c/4297379fccde28f76ebe04d085c5a4.png)
[2022 CISCN]初赛 web题目复现

C language (high-level) data storage + Practice

Initial experience of teambiion network disk (Alibaba cloud network disk)

Interviewer: what development models do you know?
随机推荐
深度学习花书+机器学习西瓜书电子版我找到了
Several important steps to light up the display
身边35岁程序员如何建立起技术护城河?
Tumor immunotherapy research prosci Lag3 antibody solution
Nesting and splitting of components
JS decorator @decorator learning notes
Introduction to abnova's in vitro mRNA transcription workflow and capping method
【Liunx】进程控制和父子进程
Kuboard can't send email and nail alarm problem is solved
Interviewer: what development models do you know?
The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
JS small exercise
Hidden Markov model (HMM) learning notes
弹性布局(二)
Abnova immunohistochemical service solution
Initial experience of teambiion network disk (Alibaba cloud network disk)
抽絲剝繭C語言(高階)指針的進階
Flexible layout (II)
修改Jupyter Notebook文件路径
毕设-基于SSM大学生兼职平台系统