<!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>
<script src="./jquery.mini.js"></script>
</head>
<style>
*{
margin: 0;
padding: 0;
}
body{
display: flex;
justify-content: center;
}
.box{
height: 600px;
width: 500px;
border: 1px solid black;
}
li{
display: none;
list-style: none;
border-bottom:1px solid black;
}
</style>
<body>
<div class="box" id="weibo">
<span>微博发布</span>
<textarea name="" class="txt" cols="30" rows="10"></textarea>
<button class="btn">发布</button>
<ul>
</ul>
</div>
<script>
$(function(){
$(".btn").on("click",function(){
var li=$("<li></li>");
li.html($(".txt").val()+"<a href='javascript:;'>删除</a>")
$("ul").prepend(li);
li.slideDown();
$(".txt").val("")
})
$("ul").on("click","a",function () {
$(this).parent().slideUp(function () {
$(this).remove();
});
})
})
</script>
</body>
</html>
jquery留言板
猜你喜欢
转载自blog.csdn.net/weiyuyang250/article/details/120804555
今日推荐
周排行