<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="js/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript">
var sumcount = 100;
$(document).ready(function () {
$('.counter').bind({
keypress:function () {
var inputText = $(this).val();
var numcount = inputText.length;
var shengcount = sumcount - numcount;
if(numcount<=sumcount)
{
$('.se').text(shengcount);
}
else if(numcount>sumcount)
{
event.preventDefault();
alert("数据已满");
}
}
});
});
</script>
</head>
<body>
<textarea class="counter" rows="10" cols="30"></textarea><br/>
<div class="se"></div>
</body>
</html>
jquery学习笔记(一)
最新推荐文章于 2024-01-20 21:49:50 发布