简体   繁体   English

jQuery适用于Firefox,但不适用于Chrome

[英]jQuery working on Firefox but not on Chrome

I've been stuck with this for a couple of days now. 我已经坚持了几天。 I'm developing a website and I've been testing it on Firefox, but what is working on Firefox is not Working on Chrome or mobile browsers like Chrome, Firefox or Dolphin HD. 我正在开发一个网站,并且已经在Firefox上对其进行测试,但是在Firefox上运行的功能无法在Chrome或Chrome,Firefox或Dolphin HD等移动浏览器上运行。

Here is the code in a jsFiddle: http://jsfiddle.net/5QMJQ/10/ 这是jsFiddle中的代码: http : //jsfiddle.net/5QMJQ/10/

What it does is get the data selected in the first five selects and add it to the last one. 它要做的是获取在前五个选择中选择的数据,并将其添加到最后一个中。 It's fine in Firefox, but in Chrome it doesn't enter in the functions. 在Firefox中很好,但在Chrome中不输入功能。 And I don't know what else to do. 而且我不知道该怎么办。

$(document).ready(function () {

     console.log('1 - Working');
     // Función que va añadiendo o quitando elementos al campo "Oficial responsable"
     // del equipo local dependiendo de los campos anteriores.
     $("#equipo_local select option").click(function () {

         console.log('2 - Working');

         ...
     });
 });

console.log('1 - Working'): FF and Chrome displays this. console.log('1-Working'):FF,Chrome会显示此内容。

console.log('2 - Working'): Only Desktop FF displays this. console.log('2-Working'):仅Desktop FF显示此内容。

Thanks for the help! 谢谢您的帮助!

I don't think click events are valid on options. 我认为点击事件对选项无效。 Instead try .change on the select? 而是在选择上尝试.change?

I suspect it's got a lot to do with how the click event is being handled on an option element. 我怀疑这与在option元素上处理click事件的方式有很大关系。

If you change your handler from click on the option , to change on the select , you'll find it works as desired. 如果您通过click optionchange处理程序,以change select ,则会发现它可以按需工作。

$("#equipo_local select").change(function () {

http://jsfiddle.net/5QMJQ/11/ http://jsfiddle.net/5QMJQ/11/

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

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