I need to create a textarea with jquery and/or javascript.
I am using this code ( click here for preview
) but backspace, enter, simbols and lowercase doesn't work. Why ?:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>TEST</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript">
<!--
$(document).keyup(function(event) {
var keyCode = event.keyCode;
$('#mytext').text(function(i, text) {
return text + String.fromCharCode(keyCode);
});
});
// -->
</script>
<style>
#cmd {
position: relative;
font-family: courier;
font-weight:bold;
font-size: 14px;
padding: 5px;
overflow: hidden;
}
#mytext {
float: left;
padding-left: 3px;
white-space: pre;
}
</style>
</head>
<body>
<div id="cmd">
<br>
<div id="mytext">hello </div>
</div>
</body>
</html>