Jquery .change在Chrome中不起作用 [英] Jquery .change isn't working in Chrome

查看:88
本文介绍了Jquery .change在Chrome中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

形成一些原因,这似乎在FF中正常工作,但在Chrome中却没有。我试过包装$(window).load(function(){...});甚至删除页面上的所有其他Javascript(除了Jquery表单向导插件。

form some reason this seems to be working fine in FF but not in Chrome. I have tried wrapping in $(window).load( function() {...}); and even removing all other Javascript on the page (other then the Jquery Form Wizard plugin.

 $('#state').change(function() {
            var state = $("#state").val();
            if (state === "CA" || state === "NV" || state === "OR" || state === "WA" || state === "AZ") {
                $("#first .ins_link_next").val("insurance_type");
                }
                else {
                $("#first .ins_link_next").val("out-of-area");

                }
    });

该页面可在 http://173.45.237.55/qrf/

非常感谢任何帮助!

推荐答案

你在input元素中有一个onKeyup处理程序,它将输入值设置为大写。这实际上分离了事件处理程序(在Chrome中)。为了解决这个问题,一个解决方案是将onKeyup函数移动到更改功能:

You have a onKeyup handler in the input element which sets the input value upper case. This actually detached the event handler (in Chrome). To fix this, one solution is to move the onKeyup function into the change function:

$('#statecode').change(function() {
        this.value=this.value.toUpperCase();
        var state = $("#statecode").val();
        if (state === "CA" || state === "NV" || state === "OR" || state === "WA" || state === "AZ") {
            $("#first .ins_link_next").val("insurance_type");
            }
            else {
            $("#first .ins_link_next").val("out-of-area");

            }
});

此外,你不需要$(window).load()来将你的函数包装在$中(文件).ready()。

Also, you do not need $(window).load() to wrap your function inside $(document).ready().

这篇关于Jquery .change在Chrome中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆