无刷新动态加载评论
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="JS/jquery-1.7.min.js"></script>
<script>
$(function () {
$("#submit").click(function () {
var tital = $("#txttital").val();
var txtarea = $("#txtarea").val();
//创建元素的时候不要写成var context = $("#<tr><td>" + tital + "</td></tr><br/><tr><td>" + txtarea + "</td></tr>");(#的区别)
var context = $("<tr><td>" + tital + "</td></tr><br/><tr><td>" + txtarea + "</td></tr>");
$("#tablecontext").append(context);
$("#txttital").val("");
$("#txtarea").val("");
})
});
</script>
</head>
<body>
<p>你可以开始评论了</p>
<table id="tablecontext">
<tr><td>匿名</td><td>沙发</td></tr>
</table>
<input type="button" id="btntital"value="tital" />
<input type="text" id="txttital"/>
<textarea id="txtarea"></textarea>
<input type="button" id="submit" value="提交"/>
</body>
</html>