<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>textArea</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
</head>
<body>
<div><textarea id="messageText" cols="45" rows="15"></textarea></div>
<div>Количество символов: <span id="symbolsCounter"></span></div>
<script type="text/javascript">
$(function() {
var ta = $("#messageText");
var counter = $("#symbolsCounter");
counter.html(ta.val().length);
if ($.browser.mozilla && $.browser.version.substr(0,3)=="1.9") {
ta.bind("input", function() {
updateCounter();
});
}
else {
ta.bind("keyup", function() {
updateCounter();
});
}
function updateCounter() {
counter.html(ta.val().length);
var split = ta.val().split("\n");
if (split.length > 15) {
ta.attr("rows", split.length);
}
}
});
</script>
</body>
</html>
Комментариев нет:
Отправить комментарий