HTML中常用的js技巧和方法
来源:互联网 发布:兄弟连培训php学费多少 编辑:程序博客网 时间:2024/05/16 07:49
以评论功能为例
1.ajax动态加载评论列表
js:
// 加载评论列表 var postId = $("#postId").html(); $.post("post/commentList.action?postId="+postId, function(data) { $("#comment-list").html(data); });
html:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><%--comment list--%><c:forEach items="${page.beanList}" var="comment" varStatus="status"> <li class="media"> <a class="pull-left" href="ta/show.action?userId=${comment.userId}"> <img class="thumbnail img-responsive center-block" src="${comment.portrait}" style="width: 65px"/> </a> <div class="media-body"> <a href="javascript:;" class="btn btn-primary btn-xs pull-right reply" onclick="replyComment('回复 #${(page.pageIndex-1)*10 + status.index + 1} ${comment.trueName}:')">回复 </a> <h4>#${(page.pageIndex-1)*10 + status.index + 1} ${comment.trueName}</h4> <small class="text-muted"><fmt:formatDate value="${comment.createTime}" pattern=" Y-M-d HH:mm "></fmt:formatDate></small> <p>${comment.content}</p> </div> </li><!-- media --></c:forEach><%--btn-load-more--%><c:if test="${page.beanList.size()>=10}"><button class="btn btn-default btn-sm btn-block" onclick="loadMoreComment(${page.pageIndex+1})" id="btn-load-more"> <i class="fa fa-plus-square-o"></i> 加载更多</button></c:if>
2.点击评论按钮,页面滚动到评论框,评论框获取焦点
$("html,body").animate({scrollTop:$("#comment-content").offset().top},500);//500是ms,也可以用slow代替
0 0
- HTML中常用的js技巧和方法
- html js 常用技巧
- 记录一些开发中常用的方法和技巧
- html页面中常用的js代码
- 常用的JS/jQuery技术和技巧
- JS中Array对象和String对象的常用方法
- js中正则表达式的常用方法和引用
- JS操作HTML节点常用到的方法和节点属性
- HTML、js:如何利用Location对象的常用属性和方法重新加载、刷新页面
- js中Object常用方法和属性
- js中Object常用方法和属性
- js中Object常用方法和属性
- 常用的JS技巧
- js的常用技巧
- js的常用技巧
- js中Math方法的小技巧
- html 中引入js css的方法
- html中添加js的方法
- CSS,font-family,好看常用的中文字体
- Python网络爬虫自动收集51CTO技术文章
- 原型模式(Prototype Pattern对象创建型模式)
- 分布式--案例(下)
- AO二次开发环境搭建
- HTML中常用的js技巧和方法
- nginx启用ssl模块以支持https
- 禁用idea的QL检查
- Jsp标签
- 等待一个消息队列中的消息,OSQPend()
- 开源 java CMS
- android_阿里WEEX js文件与原生代码数据交互
- 51nod 1085 背包问题
- 返回引用的两数相加