Jquery .on('input', function(){..});不适用于 IE

Jquery .on('input', function(){...}); not working with IE

本文关键字:IE 适用于 不适用 on input Jquery function      更新时间:2023-09-26

我在Chrome上有一个完美工作的jquery函数,但它不适用于IE...每次我在文本框中更改某些内容时,服务器都会收到 get AJAX 请求 #form 但不是在 IE 上

$("#form").on('input', function() {
    $("#value").val($("#value").val().toUpperCase());
    var postdata = {value: $("#value").val()} ;
    $.get('/search', postdata, function(data) {
        var result = ("Type : " + data['type'] + "<br/>Project name : " + data['project_name'] + "<br/>Project version : " + data['project_version'] + "<br/>Product name : " + data['product_name'] + "<br/>Product version : " + data['product_version'] + "<br/>Lib op : " + data['libop'])
        $("#print").html(result) ;
    });
});

你有解决方案吗?

谢谢!此致敬意

谢尔维茨基

使用 onkeyup 事件

$('input').keyup(function(e) {
    switch (e.which) {
        case 16: break; // Shift
        case 17: break; // Ctrl
        case 18: break; // Alt
        case 27: this.value = ''; break; // Esc: clear entry
        case 35: break; // End
        case 36: break; // Home
        case 37: break; // cursor left
        case 38: break; // cursor up
        case 39: break; // cursor right
        case 40: break; // cursor down
        case 78: break; // N (Opera 9.63+ maps the "." from the number key section to the "N" key too!) (See: http://unixpapa.com/js/key.html search for ". Del")
        case 110: break; // . number block (Opera 9.63+ maps the "." from the number block to the "N" key (78) !!!)
        case 190: break; // .
        default:
        //add your code here which will execute by default
    }
});

对不起,长帖子(在这里指定所有事件)