最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

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

Share Improve this question edited Oct 14, 2013 at 14:58 falsetru 369k66 gold badges763 silver badges658 bronze badges asked Oct 14, 2013 at 14:55 ElbbardElbbard 2,1646 gold badges34 silver badges54 bronze badges 7
  • 4 Which version of IE? The oninput event might not work in IE < 9. Try using onchange instead: $("#form").on('change', function() {. If you really need to use oninput (it's triggered as soon as the input changes, and doesn't wait for it to lose focus like onchange does), you can try this: useragentman./blog/2011/05/12/… – gen_Eric Commented Oct 14, 2013 at 14:59
  • See also, Mozilla's docs: developer.mozilla/en-US/docs/Web/API/… – gen_Eric Commented Oct 14, 2013 at 15:05
  • 1 What rocket is saying been answered before on SO, check here: stackoverflow./questions/19160902/… – lgrosales Commented Oct 14, 2013 at 15:05
  • use keyup if you need immediate events – David Fregoli Commented Oct 14, 2013 at 15:06
  • @DavidFregoli: Obviously that won't work if the text is pasted in, but it may be good enough here. – gen_Eric Commented Oct 14, 2013 at 15:08
 |  Show 2 more ments

1 Answer 1

Reset to default 6

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./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 )

发布评论

评论列表(0)

  1. 暂无评论