Jquery:即使只选择了一个子项,也在textarea中显示父项

Jquery:即使只选择了一个子项,也在textarea中显示父项,jquery,select,checkbox,parent-child,Jquery,Select,Checkbox,Parent Child,我有一个复选框列表,如果选择了子项,则会自动选择父项,然后所有选择都显示在文本区域中 问题是: 仅选择一个子项时,父项不显示在文本区域中。当选择多个子项时,将显示该选项。我需要家长将显示在文本区,即使只有一个孩子被选中 代码: Html: 更改此项: $('input.liChild').change(function() { 到 你的小提琴对我有用 //* Parent select if children selected*//

我有一个复选框列表,如果选择了子项,则会自动选择父项,然后所有选择都显示在文本区域中

问题是:

仅选择一个子项时,父项不显示在文本区域中。当选择多个子项时,将显示该选项。我需要家长将显示在文本区,即使只有一个孩子被选中

代码:

Html:

更改此项:

$('input.liChild').change(function() {

你的小提琴对我有用

                //* Parent select if children selected*//

                $(document).ready(function() {
                $('input.liChild').change(function() {
                    $(this).closest('ul')
                           .siblings('input:checkbox')
                           .prop('checked', $(this).closest('ul')
                                                   .children()
                                                   .children('input:checkbox')
                                                   .is(':checked'))
                           .first().change();
                });


                $('li.category').addClass('plusimageapply');
                $('li.category').children().addClass('selectedimage');
                $('li.category').children().hide();
                $('li.category').each(
                function(column) {
                $(this).click(function(event){
                if (this == event.target) {
                if($(this).is('.plusimageapply')) {
                $(this).children().show();
                $(this).removeClass('plusimageapply');
                $(this).addClass('minusimageapply');
                }
                else
                {
                $(this).children().hide();
                $(this).removeClass('minusimageapply');
                $(this).addClass('plusimageapply');
                }
                }
                });
                }
                );
                });

                //*Text area update*//
                function updateTextArea() {     
                   var allVals = [];
                   $('.taglist :checked').each(function(i) {

                       allVals.push((i!=0?"\r\n":"")+ $(this).val());
                   });
                   $('#describe').val(allVals).attr('rows',allVals.length) ;

                   }
                   $(function() {
                      $('.taglist input').click(updateTextArea);
                      updateTextArea();
                });
$('input.liChild').change(function() {
$('input.liChild').click(function() {