<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function checkLength() {
var textareaValue = $("#textarea_Info")[0].value;
var txtAlreadyValue = $("#txtAlready")[0].value;
var txtSurplusValue = $("#txtSurplus")[0].value;
if (textareaValue.length > 200) {
textareaValue = textareaValue.slice(0, 200);
$("#txtAlready").attr("value", 200);
$("#txtSurplus").attr("value", 0);
}
else {
$("#txtAlready").attr("value", textareaValue.length);
$("#txtSurplus").attr("value", 200 - eval(txtAlreadyValue));
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<textarea id="textarea_Info" name="textarea_Info" runat="server" rows="4" cols="50"></textarea>
<br />
<br />
已有字数:<input type="text" id="txtAlready" value="0" disabled="disabled" />
剩余字数:<input type="text" id="txtSurplus" value="200" disabled="disabled" />
</div>
</form>
</body>
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |