例子,js增加点击量。 pageEncoding="utf-8"%> String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; String groupId = request.getParameter("groupId"); %> 宝宝排行榜 <li>body { <li>text-align: center; <li>margin: 0 auto; <li>padding: 0; <li>background: #ffefe5; <li>width: 100%; <li>}<li><p>a:link { <li>text-decoration: none; <li>}<li><p>#static { <li>margin: 0 auto; <li>text-align: left; <li>}<li><p>img { <li>width: 100%; <li>}<li><p>#main { <li>background: url("../pic/bj_12.jpg") repeat-x; <li>padding-top: 5px; <li>}<li><p>#main span { <li>font-size: 1.5em; <li>color: #2f0075; <li>margin-left: 40px; <li>}<li><p>#bottom { <li>width: 100%; <li>margin: 0; <li>padding: 0; <li>font-size: 1em; <li>}<li><p>#bottom ul li { <li>width: 48%; <li>float: left; <li>margin-left: -8%; <li>margin-right:10%; <li>list-style-type: none; <li>} <li>.sp { <li>margin-top: -50px; <li>border-radius: 8px; <li>} <li> <li>$(function(){ <li>//动态加载宝贝排行信息 <li>function loadSecondSort() { <li>$.ajax({ <li>type : "POST", <li>data : "groupId="+$("#groupId").val(), <li>url : "<%=basePath%>findBobyRankByVote.action", <li>success : function(data) { <li>var list = data.list; <li>var row = ""; <li>$("ul").empty(); <li>if (list != null && list.length != 0) { <li>for(var i=0;i<list.length;i++) { <li>row = "<li><a href=\"bao_x.jsp?id="+list[i].id+"\"> <img src=\"../pic/"+list[i].pic+"\" alt="js实现点击数量添加入数据库 " ><input type=\"hidden\" id=\"id\" value="+list[i].id+"><div class=\"sp\""+ <li>"style=\"background-color: #ffb7cd; margin-top: 10px; height: 30px\">"+ <li>"<img src=\"../pic/zan.png\" style=\"width: 22px; margin-left: 10px; margin-top: 5px;\" class=\"favour\" alt="js实现点击数量添加入数据库 " >"+ <li>"<span style=\"margin-top: 5px; color: #8a7da9; float: right; margin-right: 10px;\">已<span>"+list[i].vote+"票"+ <li>" "; $(row).appendTo($("ul")); } } bbs.it-home.org } }); } $(".favour").live("click",function(){ var id = $(this).closest("li").find("#id").val(); $.post("updateBobyRank.action", "id=" + id, function(data) { if (data.msg==null){ if (data.success == true) { loadSecondSort(); } }else { alert(data.msg); } }); }); window.onload = loadSecondSort(); }); src="../pic/fan.png" style="max-width:90%"> 近期排名: 复制代码