如何在JQuery / Javascript中显示所有子元素?

时间:2018-01-15 20:13:33

标签: javascript jquery html css

我试图在jQuery中显示多个子元素,但只显示第一个子元素。我可以通过Inspect强制浏览器显示所有这些,并将css显示从none更改为block。任何人都可以帮我找到我的代码中的问题。我使用单选按钮,这是代码:

        <script type="text/javascript">
        $(document).ready(function () {
            $('#@radioButtonListSectionId input[type="radio"]
        [checked="checked"]').each(function () {
                ShowRadioButtonListDependentField(this, false);
            });
        });

        $('#@radioButtonListSectionId input[type="radio"]').change(function 
        () {
            var result = $(this).val();
            $('#@uniqueID-hidden').val(result);
            ShowRadioButtonListDependentField(this, false);

        });
        function ShowRadioButtonListDependentField(element, show) {
            debugger;
            var fieldKey = $(element).val(), children;
            var currentId = element.attributes["currentid"].value;
            if (currentId != 0) {
                if ($('.main-dialogbox.modal.fade.in').length > 0)
                    children = $('.modal-body .control-group[parentid=' + 
            currentId + ']');
                else if ($('.idea-task.open').length > 0)
                    children = $('.idea-task .control-group[parentid=' + 
           currentId + ']');
                else
                    children = $('.control-group[parentid=' + currentId + 
            ']');
                if ($(element).is(":checked") && $(element).is(":visible"))
                    show = true;
                else
                    show = false;
                children.hide();
                children.each(function () {
                    var keys = 
                this.attributes["parentOptionKey"].value.split("</br>");
                    var haschildren = this.attributes["haschildren"].value;
                    for (var i = 0; i < keys.length; i++) {
                        if (keys[i] == fieldKey) {
                            if (show) {
                                $(this).show();
                                show = false;

                    $(this.getElementsByClassName("ishidden")).val("False");
                            } else {
                                $(this).hide();

                    $(this.getElementsByClassName("ishidden")).val("True");
                                if (haschildren.toLowerCase() == "true") {
                                    ShowCheckListDependentField(this, 
                     false);
                                }
                            }
                        }
                        else {

       $(this.getElementsByClassName("ishidden")).val("True");
                        }
                    }
                });
            }
        }
    </script>

0 个答案:

没有答案