正如标题所说,这是我在 jsfiddle 上运行的代码:http: //jsfiddle.net/paopaomj/zgGpN/
我复制了本地计算机上的所有代码(用括号编辑),但未能运行,我错过了什么?(这里忽略css样式)
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.0.2.min.js"></script>
<!--<script type="text/javascript" src="tools.js"></script>-->
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script>
$document.ready(function(){
$("#command").keyup(function (e) {
if (e.keyCode == 13) {
submit();
}
});
var submit = function () {
var commandEl = document.getElementById("command");
var command = commandEl.value;
var outputel = document.getElementById("output");
var new_row = document.createElement("div");
new_row.innerHTML = "root@host# > " + command;
outputel.appendChild(new_row);
commandEl.value="";
};
})
</script>
<div id="output"></div>
<div id="input">
root@host# >
<input type="text" id="command" />
</div>
</body>
</html>