gadget|gadget : jQuery实现发微博案例
实现点击发送文本框中的内容到指定位置
用到jQuery方法 :prepend() slideDown()
代码如下
html
css
*{
margin: 0;
padding: 0;
}
body{
background: rgb(77, 159, 226);
}
/* box */
#box{
width: 700px;
margin: 50px auto 10px;
background: #ffffff;
padding: 10px;
box-sizing: border-box;
text-align: right;
border-radius: 5px;
}
#box textarea{
width: 680px;
height: 160px;
resize: none;
}
#box button{
width: 80px;
height: 30px;
}
/* ul */
ul{
width: 700px;
list-style: none;
margin: auto;
}
ul li{
line-height: 30px;
border-radius: 5px;
background: #ffffff;
box-sizing: border-box;
padding-left: 10px;
margin-bottom: 10px;
}
【gadget|gadget : jQuery实现发微博案例】js
$(function(){
$('button').click(function(){
let val = $('#box textarea').val();
$('#box textarea').val('');
// console.log(val)
//当输入框为空时,不能发送
if(val !=''){
var ele =''+val+' '
$('ul').prepend(ele);
$('ul li:first').hide().slideDown();
}else{
alert('请输入内容!')
}
})
})
推荐阅读
- 关于QueryWrapper|关于QueryWrapper,实现MybatisPlus多表关联查询方式
- MybatisPlus使用queryWrapper如何实现复杂查询
- python学习之|python学习之 实现QQ自动发送消息
- 事件代理
- 孩子不是实现父母欲望的工具——林哈夫
- opencv|opencv C++模板匹配的简单实现
- Node.js中readline模块实现终端输入
- java中如何实现重建二叉树
- 人脸识别|【人脸识别系列】| 实现自动化妆
- paddle|动手从头实现LSTM