***********************************js对象
Cms.upf = function(base, feelingcountid, origValue, upId, type) { var updown = $.cookie("_cms_up_" + feelingcountid); if (updown) { //当前cookie是否存在,存在就已经发布过了, 不存在就没有发表 alert("-_- !,您已经发表过了哦~~"); return false; } $.cookie("_cms_up_" + feelingcountid, "1"); $.get(base + "/feelingcount_up.jspx", { //数据库+1 "feelingcountid" : feelingcountid, "type" : type }, function(data) { var high = origValue + 1; var top = 70 - high; $("#moodc" + upId).html(high); if(high<70){ $("#moodh" + upId).css("height",high); $("#moodh" + upId).css("margin-top",top); }else{ $("#moodh" + upId).css("height",high); $("#moodh" + upId).css("margin-top",10); } }); return true;};************************************页面加载就查找库,当前文章的开心数 $.ajax({ type : "post", url : "${base}/feelingcount_list.jspx", data:"id=${content.id}", dataType : "text", contentType: "application/x-www-form-urlencoded; charset=UTF-8", success : function(json){ json = decodeURI(json); //js解码 json = eval("("+json+")"); //转换为json对象 $(json).each(function(index) { var val = json[index]; if(val.dic_id == 16 ){ //点击当前文章的点击数+1;前提是库中点击数添加成功以后,才能+1 $(".like_unlike").append("<a οnclick=\"Cms.upf('${base}'," +val.content_id+","+val.click_count+","+val.id+","+val.dic_id+");\" class=\"like\"><span>喜欢<em id=\"moodc"+val.id+"\">" +val.click_count+"</em></span></a>" ); }else if(val.dic_id == 17){ $(".like_unlike").append("<a οnclick=\"Cms.upf('${base}'," +val.content_id+","+val.click_count+","+val.id+","+val.dic_id+");\" class=\"unlike\"><span>不喜欢<em id=\"moodc"+val.id+"\">" +val.click_count+"</em></span></a>" ); } }); }, error:function(json){ } });***********************************html<!--心情状态--><div class="like_unlike"><div class="clr"></div></div>