<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="./js/jquery-1.11.3.min.js"></script> <title>Document</title> <style> #current{ color: red; } </style> </head> <body> <textarea cols="80" rows="5" id="textarea" name="" maxlength="12"></textarea> <span id="current">0</span>/<span id="all">12</span> <script type="module"> $('textarea').bind('input propertychange',function(e){ $('#current').text(e.target.value.length) }) </script> </body> </html>
效果: