addeventListener有问题

时间:2018-06-14 15:36:51

标签: javascript events dom

document.addEventListener("DOMContentLoaded", function (event) {
    alert("Got into DOMContentLoaded event");
    document.getElementById("txtSearch").addEventListener("onkeyup", function () {
        //TODO Post to server
        alert("Got into onKeyUp event");
        var data;
        var xhttp = new XMLHttpRequest();
        xhttp = XMLHttpRequest();
        xhttp.open("POST", "/Home/searchLocs", true);
        xhttp.setRequestHeader("Content-Type", "application/json");
        var obj = { "strSearch": document.getElementById("txtSearch").value }
        xhttp.send(JSON.stringify(obj));
    });
    alert("Got past search addEventListener");
    alert("onkeyup = " + document.getElementById("txtSearch").onkeyup);
});

我正在尝试将javascript事件处理程序连接到

<input type="text" id="txtSearch" style=" width:200px" />
警告告诉我我 进入DOMContentLoaded事件, 我越过了addeventListener, 但是onkeyup = null。 IE vs 11+ 我的addEventListener语法有问题吗?

1 个答案:

答案 0 :(得分:0)

要修复此替换

import numpy
for y1, y2, y3 in numpy.ndindex(x2, x4, ...):
    ...

 addEventListener("onkeyup", function ()