简体   繁体   English

jQuery模糊在IE8和IE7上不起作用

[英]jQuery blur doesn't work at IE8 and IE7

I have the following code: 我有以下代码:

jQuery(document).ready(function ($) {
    // ...
    Sys.Application.add_load(function () {
        $(".RadGrid td > .RadInput.RadInput_Default > .riTextBox.riEnabled").each(function () {
            $(this).val($(this).val().replace(/,/g, ""));
        });

        $(".RadGrid td > .RadInput.RadInput_Default > .riTextBox.riEnabled").blur(function () {
            $(this).val($(this).val().replace(/,/g, ""));
        });
    });
}

The reason I have written this code is that I'm using Telerik RadGrid which has some autogenerated columns and a column filter, which formats the value of integer column filter values. 我写这段代码的原因是,我正在使用Telerik RadGrid,它具有一些自动生成的列和一个列过滤器,该过滤器格式化整数列过滤器值的值。 For example 1000000 becomes 1,000,000. 例如1000000变成1,000,000。 It works fine, but I have to get rid of the formatting because it bothers some people. 它工作正常,但我必须摆脱格式设置,因为它会打扰某些人。 Essentially the HTML elements we are talking about are inputs and they are modified by telerik and can be found with the selector you see in the code. 本质上,我们正在谈论的HTML元素是输入,它们由telerik进行了修改,并且可以在代码中看到的选择器中找到。 I want to make sure that the users will never see comma in these inputs. 我想确保用户在这些输入中永远不会看到逗号。 My code works well in google Chrome, FF and IE9, but it fails to work with IE8 and IE7. 我的代码在Google Chrome,FF和IE9中效果很好,但在IE8和IE7中无法正常工作。 In fact after loading my page I don't see commas, however, if I edit them end focus out of the items, the commas appear. 实际上,在加载页面之后,我看不到逗号,但是,如果我编辑它们,并且将焦点从项目中移出,则会出现逗号。 These issues are applicable only in IE8 and IE7. 这些问题仅适用于IE8和IE7。 How can I fix my code to work in Chrome, FF, IE9, IE8 and IE7? 如何修复我的代码以在Chrome,FF,IE9,IE8和IE7中运行?

Thank you in advance for any help. 预先感谢您的任何帮助。

Best regards, 最好的祝福,

Lajos Árpád. LajosÁrpád。

From the JQuery documentation : JQuery文档中

The blur event is sent to an element when it loses focus. 当模糊事件失去焦点时,会将其发送到元素。 Originally, this event was only applicable to form elements, such as <input>. 最初,此事件仅适用于表单元素,例如<input>。 In recent browsers, the domain of the event has been extended to include all element types. 在最近的浏览器中,事件的域已扩展为包括所有元素类型。

So if, as I guess, riTextBox is a class of some span containing an input, this should work: 因此,按照我的猜测,如果riTextBox是包含输入的某个范围的类,则此方法应该有效:

    $(".RadGrid td > .RadInput.RadInput_Default > .riTextBox.riEnabled input")
       .blur(function () {
                 $(this).val($(this).val().replace(/,/g, ""));
    });

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

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