简体   繁体   English

jQuery脚本在Internet Explorer中不起作用

[英]Jquery Script not working in Internet Explorer

I have this script working fine in Chrome but in IE 8 or 9, this code is not working: 我的脚本在Chrome中工作正常,但在IE 8或9中,此代码无法正常工作:

$(document).on("mousedown", '#CentroCusto_new option', function (event) {
    debugger;
    alert('oi');
    event.returnValue = false;
    this.selected = !this.selected;
    event.preventDefault();
});
  • In IE: F12 is open. 在IE中:F12打开。
  • Debugger and Alert is not called. 不调用调试器和警报。
  • jQuery v1.10.2 jQuery v1.10.2
  • No errors in console. 控制台中没有错误。
  • I tried to change document to 'body', but not working too. 我试图将文档更改为“正文”,但也无法正常工作。
  • When I remove option, function is called 当我删除选项时,函数被调用

How to solve this? 如何解决呢? I think IE is not accepting this selector, but why? 我认为IE不接受此选择器,但是为什么呢?

JSFIDDLE 的jsfiddle

debugger; is pausing execution of your code - which is why alert() isn't firing 正在暂停执行您的代码-这就是为什么alert()不触发的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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