2
我試圖使用jQuery在文本區域計數字符,這裏是我迄今爲止..JQuery的文本區域字符數
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#textfield").on('keyup, paste', function(){
var Characters = ("#textfield").val().replace(/(<([^>]+)>)/ig,"").length;
$("#counter").text("Characters left: " + (1500 - Characters));
});
});
</script>
</head>
<body>
<form id="input_form" method="POST" action="?">
<textarea id="textfield"></textarea>
</form>
<div id="counter"></div>
</body>
</html>
沒有被輸出到我的div ...任何想法爲什麼?
仍然一無所獲:( – Brian