Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery在一组广播框上显示/隐藏,然后很快隐藏div_Javascript_Jquery - Fatal编程技术网

Javascript jQuery在一组广播框上显示/隐藏,然后很快隐藏div

Javascript jQuery在一组广播框上显示/隐藏,然后很快隐藏div,javascript,jquery,Javascript,Jquery,我的代码工作得很好,当我需要它时它会显示出来,当我需要它消失时它会隐藏起来。这里的想法是,当使用表单时,使用表单的人可以选中一个框,查看他们刚刚选中的内容的更多必需表单数据,这会使这些字段成为必需的,当用户取消选中该框时,它就会消失 唯一的问题是,当用户单击组中的radio box,但radio box没有正确的值来显示容器容器(例如我的false条件)时,jQuery将非常快速地显示该框,然后再次隐藏它。在我的代码中是否有一种方法可以在条件不正确的情况下隐藏该框,并且如果他们切换到其他框,它将

我的代码工作得很好,当我需要它时它会显示出来,当我需要它消失时它会隐藏起来。这里的想法是,当使用表单时,使用表单的人可以选中一个框,查看他们刚刚选中的内容的更多必需表单数据,这会使这些字段成为必需的,当用户取消选中该框时,它就会消失

唯一的问题是,当用户单击组中的radio box,但radio box没有正确的值来显示容器容器(例如我的false条件)时,jQuery将非常快速地显示该框,然后再次隐藏它。在我的代码中是否有一种方法可以在条件不正确的情况下隐藏该框,并且如果他们切换到其他框,它将隐藏用户正在查看的框?如果是,怎么做

这是我的密码:

        var hiddenClassArray = [
                    "appliedWorkedYes",
                    "workStudyYes",
                    "workHistoryYes",
                    "workWeekEndsYes",
                    "cprYes",
                    "aedYes",
                    "aidYes",
                    "lifegaurd",
                    "wsiYes",
                    "gaurdYes",
                    "lifegaurdChk",
                    "fitnessChk",
                    "fitPTCYes",
                    "fitGrpYes",
                    "outdoorAdvChk",
                    "challengeChk",
                    "injuryCareChk",
                    "athTrainYes",
                    "serviceCenter",
                    "itDepartmentChk",
                    "marketingChk", 
                    "personalTrainer",
                    "yogaInstructr",
                    "IndoorCyclingInstructr",
                    "grpFitInstruct",
                    "pilatesInstructr",
                    "itDepartmentChk",
                    "marketingChk",
                    "yogaInstructr",
                    "cyclingInstructr",
                    "personalTrainerChk",
                    "yogaInstructorChk",
                    "IndoorCyclingInstructorChk",
                    "grpFitInstructChk",
                    "pilatesInstructChk",
                    "itDepartmentChk2",
                    "climbAssistant",
                    "priorWrkName",
                    "priorWrkSalary",
                    "priorWrkTitle",
                    "priorWrkSupervisor",
                    "priorWrkStartDate",
                    "priorWrkEndDate",
                    "priorWrkReasonForLeaving",
                    "officeUseStatus"
                    ];  

        // looping over each array element, hiding them using jQuery
        for(var i = 0; i < hiddenClassArray.length; i++){
            // jQuery to append a display none. 
            $("."+hiddenClassArray[i]+"Hide").css("display","none");    
        }

        // ************ RADIO & CHECK BOXES ************

    // jQuery's Equlivant of a for each loop, a little fancier then that 
    // This appears to work better then the for loop above, but the for loop above
    // has no problems but it did for this set. 
    $.each(hiddenClassArray, function(index, radio) {

        // first is it a Check box? 
        if($("."+radio).is(':checkbox')) {
            // when we click
            $("." + radio).click(function() {
                // if it's checked show
                if($("."+ radio).attr('checked')){
                    // show
                    $("." + radio + "Hide").show('fast'); 
                    // make one of the group required
                    $("."+ radio + "Required").addClass("required");
                }
                // default hide
                else{ 
                    // hide 
                    $("."+ radio + "Hide").hide("fast");
                    // remove the required class attribute
                    $("."+ radio + "Required").removeClass("required");
                }
            }); // ends .click
        } // ends if
        // if it's a radio box
        else if ($("."+radio).is(':radio')) {
            // On click
            $("."+radio).click(function(){
                // show
                if($(this).val()==="True"){                         
                    // show
                    $("."+radio + "Hide").show("fast");
                    // make one of the group required
                    $("."+radio + "Required").addClass("required");
                    alert("Got here ! ");
                }
                else if($(this).val()=="nc"){
                    $("."+radio + "Hide").show("fast");
                }
                // default, hide
                else{ 
                    // hide
                    $("."+radio + "Hide").hide("fast");
                    // remove the required class attribute
                    $("."+radio + "Required").removeClass("required");
                }
            }); // emds .click

        }// ends else
    }); // end .each
var hiddenclassrarray=[
“应用工作染料”,
“工作研究”,
“工作历史是”,
“工作周是”,
“是的”,
“是的”,
“是的”,
“生命之歌”,
“wsiYes”,
“戈尔德耶斯”,
“生命之歌”,
“fitnessChk”,
“Fitpcyes”,
“fitGrpYes”,
“户外广告”,
“挑战者”,
“伤害车”,
“是的”,
“服务中心”,
“itDepartmentChk”,
“营销CHK”,
“私人教练”,
“yogaInstructr”,
“IndoorCyclingStructor”,
“grpFitInstruct”,
“PilatesinStructor”,
“itDepartmentChk”,
“营销CHK”,
“yogaInstructr”,
“CyclingInstructor”,
「个人培训香港」,
“yogaInstructorChk”,
“IndoorCyclingStructorCHK”,
“grpFitInstructChk”,
“Pilatesinstrucchk”,
“IT部门CHK2”,
“登山助手”,
“priorWrkName”,
“priorWrkSalary”,
“Priorwrktille”,
“首席监督官”,
“priorWrkStartDate”,
“priorWrkEndDate”,
“Priorwrkreasonforleving”,
“公务员身份”
];  
//在每个数组元素上循环,使用jQuery隐藏它们
对于(var i=0;i
尝试替换以下代码

$.each(hiddenClassArray,函数(索引,收音机){


我认为这是造成闪烁问题的原因。你可以试着在show方法中给出一些数字,比如100/200,以使动画持续数毫秒。
    // first is it a Check box? 
    if($("."+radio).is(':checkbox')) {
        // when we click
        $("." + radio).click(function() {
            // if it's checked show
            if($("."+ radio).is(':checked')){
                // show
                $("." + radio + "Hide").show(); 
                // make one of the group required
                $("."+ radio + "Required").addClass("required");
            }
            // default hide
            else{ 
                // hide 
                $("."+ radio + "Hide").hide();
                // remove the required class attribute
                $("."+ radio + "Required").removeClass("required");
            }
        }); // ends .click
    } // ends if
    // if it's a radio box
    else if ($("."+radio).is(':radio')) {
        // On click
        $("."+radio).click(function(){
            // show
            if($(this).val()==="True"){                         
                // show
                $("."+radio + "Hide").show();
                // make one of the group required
                $("."+radio + "Required").addClass("required");
                alert("Got here ! ");
            }
            else if($(this).val()=="nc"){
                $("."+radio + "Hide").show();
            }
            // default, hide
            else{ 
                // hide
                $("."+radio + "Hide").hide();
                // remove the required class attribute
                $("."+radio + "Required").removeClass("required");
            }
        }); // emds .click

    }// ends else
}); // end .each