Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
日食及;Javascript_Java_Javascript_Jquery_Html_Eclipse - Fatal编程技术网

日食及;Javascript

日食及;Javascript,java,javascript,jquery,html,eclipse,Java,Javascript,Jquery,Html,Eclipse,我已经安装了Eclipse和Web开发工具——我正在尝试在Eclipse中编写Java脚本,但想知道是否需要其他特定的插件/工具包。目前,我使用以下方式构建: File -> New -> Web -> Dynamic Web Project || File -> New -> HTML File || File -> New -> JSP File 能够将JavaScript作为我正在学习/使用的材料运行。但是,我无法在Eclipse环境中拥有任何J

我已经安装了Eclipse和Web开发工具——我正在尝试在Eclipse中编写Java脚本,但想知道是否需要其他特定的插件/工具包。目前,我使用以下方式构建:

File -> New -> Web -> Dynamic Web Project ||
File -> New -> HTML File ||
File -> New -> JSP File
能够将JavaScript作为我正在学习/使用的材料运行。但是,我无法在Eclipse环境中拥有任何JavaScript事件处理功能

例如,我有以下HTML文件:




但是HTML不会触发内部函数main中的Javascript——但是它会发送第一个警报()。同时,当我将文件移动到计算机上的某个目录时,javascript警报会工作,但事件读取器不会工作

这里使用的是jQuery语法:
$(文档)
但是您还没有将jQuery框架包含到html文件中。添加jQuery,它应该可以工作:

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

谢谢你的帮助!我一直在学习在线课程,但他们忽略了关于包含jQuery库的内容
---------------------


alert("inside keyboardTest.js");

var main = function(){

$(document).keypress(function(event){
    alert("HERE");
     if(event.which === 65){
        /** A  **/
        alert("A");
    }
    else if(event.which == 69){
         /** E  **/
        alert("E");
    }
     else if(event.which===70){
        /** F  **/
        alert("F");
    }
    else if(event.which===32){
        /** SPACE_BAR **/
        alert("space_bar");
    }
});
}


$(document).ready(main)`
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>