javascript - I have my code running on jsfiddle, but why can't on local computer? -
as title said, code running on jsfiddle: http://jsfiddle.net/paopaomj/zggpn/
and copy code on local computer (edit brackets),but failed run, miss? (ignoring css style here)
<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>
use either,
$(document).ready(function() { // handler .ready() called. });
or
$(function() { // handler .ready() called. });
instead of
$document.ready(function(){ // handler .ready() called. });
Comments
Post a Comment