1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| $(function () { $("body").delegate(".comment","propertychange input", function () { if($(this).val().length > 0){ $(".send").prop("disabled", false); }else{ $(".send").prop("disabled", true); } }); $(".send").click(function () { var $text = $(".comment").val(); var $weibo = createEle($text); $(".messageList").prepend($weibo); });
$("body").delegate(".infoTop", "click", function () { $(this).text(parseInt($(this).text()) + 1); }); $("body").delegate(".infoDown", "click", function () { $(this).text(parseInt($(this).text()) + 1); }); $("body").delegate(".infoDel", "click", function () { $(this).parents(".info").remove(); });
function createEle(text) { var $weibo = $("<div class=\"info\">\n" + " <p class=\"infoText\">"+text+"</p>\n" + " <p class=\"infoOperation\">\n" + " <span class=\"infoTime\">"+formartDate()+"</span>\n" + " <span class=\"infoHandle\">\n" + " <a href=\"javascript:;\" class='infoTop'>0</a>\n" + " <a href=\"javascript:;\" class='infoDown'>0</a>\n" + " <a href=\"javascript:;\" class='infoDel'>删除</a>\n" + " </span>\n" + " </p>\n" + " </div>"); return $weibo; }
function formartDate() { var date = new Date(); var arr = [date.getFullYear() + "-", date.getMonth() + 1 + "-", date.getDate() + " ", date.getHours() + ":", date.getMinutes() + ":", date.getSeconds()]; return arr.join("");
} });
|