Javascript $(文档).on(';change';,';.phoneCountry';,函数(){在IE9中不工作

Javascript $(文档).on(';change';,';.phoneCountry';,函数(){在IE9中不工作,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,在IE9$(document).on('change'),不适用于IE9。.phoneCountry是选中时需要一些其他数据的下拉列表 $(document).on('change', '.phoneCountry', function () { // event.preventDefault(); if ('console' in window) console.log("$('.phoneCountry').change"); if ($(".p

在IE9
$(document).on('change'),
不适用于IE9。
.phoneCountry
是选中时需要一些其他数据的下拉列表

$(document).on('change', '.phoneCountry', function () {
    //    event.preventDefault();
        if ('console' in window) console.log("$('.phoneCountry').change");
        if ($(".phoneCountry").val() != "Select") {
            //reset the controls
            $("#phonecountrycode").val('');
}

有什么问题吗?

定义“不工作”。你使用的是什么版本的jQuery,你能给出一个完整的例子吗?从dom的结构到无效的html.console.log在IE中都是不存在的。试着摆脱它,然后再试一次。你的if也有点奇怪。它通常类似于
if(console&concosle.log)
我认为,但一般来说,这只适用于基于webkit的浏览器,并扼杀了IERe@ppumkin的观点:它存在,只有当您打开开发工具时才存在。正确的检查是
if(typeof console!=“undefined”)console.log(…)
但你所做的也可能有用。@ppumkin:两者都有。还有9。和10。不知道Edge。