未定义的引用$未定义

时间:2017-08-20 13:59:59

标签: javascript jquery html function keyboard

我正在尝试使用javascript使用键上的事件来在屏幕上显示字母表,我仍然坚持这个错误。请帮忙

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.2/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>

<script src="script.js" charset="utf-8"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  </body>
</html>

This is the script file that I'm using

的script.js

(document).keydown(function(event) {
  if (event.which === 13) {
    console.log("you pressed");
  }
});

2 个答案:

答案 0 :(得分:1)

您在jQuery之前运行脚本,因此apr_socket_connect(): No connection could be made because the target machine actively refused it. 尚不存在。

答案 1 :(得分:1)

放置

$

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>