<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>监听多行文本框字数输入变化-细数逝去的过往</title> | |
<style type="text/css"> | |
textarea { | |
500px; | |
height: 200px; | |
} | |
</style> /*引入自己的目录文件jQuery版本JS便可*/ |
|
<script type="text/javascript" src="static/web-v2.0/js/lib/jquery.js"></script> | |
<script type="text/javascript"> | |
//监听文本域输入,显示变化 | |
$(document).ready(function() { | |
$(document).on("keyup", ".textarea_input", function() { | |
var _index = $(".textarea_input").index(this); | |
var show_length = (1000 - $(".textarea_input").eq(_index).val().length); | |
$(".tips").eq(_index).text(show_length) | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<textarea class="textarea_input">描述具体项目内容</textarea> | |
<p class="input_work_tip">您还可以输入<span class="tips">1000</span>字</p> | |
</body> | |
</html>
|