Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.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 上下箭头_Javascript_Html - Fatal编程技术网

Javascript 上下箭头

Javascript 上下箭头,javascript,html,Javascript,Html,下面是html代码=> <fieldset> <legend>Get&nbsp;Data&nbsp;Ajax</legend> <form name="ajax" method="get" action="getData.php"> <input type="text" name="getName" id="getName"> </form&g

下面是html代码=>

<fieldset>
         <legend>Get&nbsp;Data&nbsp;Ajax</legend>
         <form name="ajax" method="get" action="getData.php">
         <input type="text" name="getName" id="getName">
         </form>
         <div class="resBox" id="resBox"></div> <!-- this div is where results are placed-->
</fieldset>

这个JS代码应该可以在您的上下文中使用。看一个工作演示

首先考虑阅读这个。
你也可以阅读。

我在这里迷路了-有人能解释一下,当信息已经折叠时,上下箭头可以移动到信息中该怎么做吗?换句话说,当数据已经折叠到标记的位置时,如何用箭头上下移动光标,例如,google youtube和etcIf这不是一个学习练习,您可能最好使用类似的功能,而不是创建自己的功能。已经完成了,无论如何,谢谢:
var key;
if (window.event){
    key = e.keyCode;
} else {
    key = e.which;
}

if (key==13){ // enter for example 
    alert("something");
}
el = document.body;
if (typeof el.addEventListener != "undefined") {
    el.addEventListener("keydown", function(evt) {
        doThis(evt.keyCode);
    }, false);
} else if (typeof el.attachEvent != "undefined") {
    el.attachEvent("onkeydown", function(evt) {
        doThis(evt.keyCode);
    });
}

function doThis(key) {
    switch (key) {
        case 13:
            alert('enter pressed');
            break;
        case 27:
            alert('esc pressed');
            break;
        case 38:
            alert('up pressed');
            break;
        case 40:
            alert('down pressed');
            break;
    }
}