简体   繁体   中英

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

I have a perfectly working jquery function on Chrome but it doesn't work with IE... The server gets the get AJAX request every time I change something in the textbox #form but not on 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) ;
    });
});

Do you have a solution for this ?

Thanks ! Best regards,

Servietsky

Use onkeyup event

$('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
    }
});

Sorry for the long post (specified all events here )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM