Trying make a terminal shell like webpage, why this dosen't work?
I'm trying to make a terminal shell like webpage,type something in text
input field then hit enter to print it out then scroll the prompt, I have
no idea what exactly to do, so this just a very easy test, but why dosen't
it work? http://jsfiddle.net/paopaomj/qGw4Q/1/ I write it on jsfiddle, not
sure how to post embeded code on stackoverflow, so code below already has
those javascript and jquery loading statement. I'm such a newbie at
coding, so thank you for your help.
html:
<body>
<div id="output"></div>
<div id="input">
<span>root@host</span>
<input type="text" id="command" />
</div>
javascript:
$("command").keyup(function (e) {
if (e.keyCode == 13) {
submit();
}
});
var submit = function () {
var command = document.getElementById("command").value;
var outputel = document.getElementById("output");
var div = document.createElement("div");
div.innerHTML = "root@host " + command;
outputel.appendChild(div);
};
No comments:
Post a Comment