网页特效栏目收集了最全最新的前端网页插件,包括最流行的jQuery,Bootstrap,Js,Css,Vue等主流特效插件。
这是一款非常好用的jquery无刷新评论回复插件。
使用方法:
在页面中引入js文件和jquery代码(数据是本地模拟的):
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.comment.js" ></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript">
//初始化数据
var arr = [
{id:1,img:"./images/img.jpg",replyName:"帅大叔",beReplyName:"网友",content:"人往往以两种方式生存,一种是追随社会,另一种则是遵循自然。",time:"2017-10-17 11:42:53",address:"北京",osname:"",browse:"谷歌",replyBody:[]},
{id:2,img:"./images/img.jpg",replyName:"网友",beReplyName:"",content:"青春是美丽的,却是很短暂。现实是残酷的,伹必须面对。”",time:"2017-10-17 11:42:53",address:"北京",osname:"",browse:"谷歌",replyBody:[{id:3,img:"",replyName:"帅大叔",beReplyName:"网友",content:"来啊,我们一起吃鸡",time:"2017-10-17 11:42:53",address:"",osname:"",browse:"谷歌"}]},
{id:3,img:"./images/img.jpg",replyName:"帅大叔",beReplyName:"网友",content:"不能自娱自乐的人,很容易会对别人产生不满。",time:"2017-10-17 11:42:53",address:"北京",osname:"win10",browse:"谷歌",replyBody:[]}
];
$(function(){
$(".comment-list").addCommentList({data:arr,add:""});
$("#comment").click(function(){
var obj = new Object();
obj.img="./images/img.jpg";
obj.replyName="网友";
obj.content=$("#content").val();
obj.browse="北京";
obj.osname="win10";
obj.replyBody="";
$(".comment-list").addCommentList({data:[],add:obj});
});
})
</script>
html代码:
<div class="container">
<div class="commentbox">
<textarea cols="80" rows="50" placeholder="来说几句吧......" class="mytextarea" id="content"></textarea>
<div class="btn btn-info pull-right" id="comment">评论</div>
</div>
<div class="comment-list">
</div>
</div>
css样式代码:
<style>
.container{
width: 1000px;
}
.commentbox{
width: 900px;
margin: 20px auto;
}
.mytextarea {
width: 100%;
overflow: auto;
word-break: break-all;
height: 100px;
color: #000;
font-size: 1em;
resize: none;
}
.comment-list{
width: 900px;
margin: 20px auto;
clear: both;
padding-top: 20px;
}
.comment-list .comment-info{
position: relative;
margin-bottom: 20px;
margin-bottom: 20px;
border-bottom: 1px solid #ccc;
}
.comment-list .comment-info header{
width: 10%;
position: absolute;
}
.comment-list .comment-info header img{
width: 100%;
border-radius: 50%;
padding: 5px;
}
.comment-list .comment-info .comment-right{
padding:5px 0px 5px 11%;
}
.comment-list .comment-info .comment-right h3{
margin: 5px 0px;
}
.comment-list .comment-info .comment-right .comment-content-header{
height: 25px;
}
.comment-list .comment-info .comment-right .comment-content-header span,.comment-list .comment-info .comment-right .comment-content-footer span{
padding-right: 2em;
color: #aaa;
}
.comment-list .comment-info .comment-right .comment-content-header span,.comment-list .comment-info .comment-right .comment-content-footer span.reply-btn,.send,.reply-list-btn{
cursor: pointer;
}
.comment-list .comment-info .comment-right .reply-list {
border-left: 3px solid #ccc;
padding-left: 7px;
}
.comment-list .comment-info .comment-right .reply-list .reply{
border-bottom: 1px dashed #ccc;
}
.comment-list .comment-info .comment-right .reply-list .reply div span{
padding-left: 10px;
}
.comment-list .comment-info .comment-right .reply-list .reply p span{
padding-right: 2em;
color: #aaa;
}
</style>
以上就是jquery无刷新评论回复插件的代码,需要的朋友可以登录后下载。更多实用网页代码请关注帝国模板之家。
转载请注明来源:jquery无刷新评论回复插件代码
本文永久链接地址:https://www.moyouyouw.cn/code/510.html
郑重声明:本站所有主题/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除,谢谢!我们不承担任何技术及版权问题,且不对任何资源负法律责任。
已有 位小伙伴发表了看法
欢迎 你 发表评论