Thursday, September 16, 2010

Editable DIV With character count

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>Editable DIV and character count</title>

<script src="jquery-1.4.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
/*
$(document).ready(function(){
alert($("#content").text().length);
});
*/
</script>


</head>

<body>

<div id="content" contenteditable="true" style="border:1px solid #f00;">ABC</div>

<script type="text/javascript">

var count = document.getElementById("content").innerHTML.length;
alert(count);

</script>


</body>

</html>

1 comment: