<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML editor</title>
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
<style>
textarea{
width:600px;
height: 450px;
}
</style>
</head>
<body>
<textarea name=""></textarea>
<input type="text" name="">
<br/>
<span id="mochu"></span>
<script>
$('body').on('input propertychange','.texts,.inputtext',function(){
$('#mochu').html('当前字数:'+$(this).val().length);
});
</script>
</body>
</html>
jq 监听 input 与 textarea 内容时时变化的方法
最新推荐文章于 2023-05-24 11:39:16 发布