簡體   English   中英

單擊字段后 IE 失去焦點

[英]IE lose focus after field has been clicked into

我在無效/空白條目的表單上顯示了一個錯誤層。 當出現該錯誤層時,我希望當前字段失去焦點。 在 IE 中,我無法讓它工作。 焦點始終停留在該領域。

    <!--Jquery function to override JS alert with DOM layer alert message-->
function customAlert(){
    var args = arguments;
    if(args.length > 1) {
        // check that custom alert was called with at least two arguments
        var msg = args[0];

        $("li").removeClass("alertRed");
        $("input").removeClass("CO_form_alert");
        $("select").removeClass("CO_form_alert");
        var div = $(".errorPopup");
        div.css({"display":"block"});


        if (div.length == 0) {
            div = $("<div class='errorPopup' onclick='$(this).hide();'></div>");
            $("body").prepend(div);
        }
        div.html(msg);
        for(var i = 1; i < args.length; i++) {
            var inputID = args[i];
           $("#"+inputID).addClass("CO_form_alert").parent().addClass("alertRed");
            $("input,select,radio,checkbox").focus(function(){
                $(this).unbind('focus'); // remove this handler
                $('.errorPopup').hide(); // hide error popup

            });


        }
     }
}

我試過 ('body').focus(); 和 $("#"+inputID).focusout(); 這也不起作用。

我也試過:

div.css({"display":"block"});
$("input,select,radio,checkbox").blur();

$("input,select,radio,checkbox").blur(function(){
                $(this).unbind('focus'); // remove this handler
                $('.errorPopup').hide(); // hide error popup

            });

但沒有一個有效。

使用模糊方法。

$("input,select,radio,checkbox").blur();

你試過了嗎

$("input,select,radio,checkbox").blur();

?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM