多级选择

时间:2016-08-24 10:08:23

标签: javascript html backbone.js handlebars.js

我需要选择:

Object
- Children
- Children 2
-- Children
--- Test
-- Children 2
--- Test
---- Test
--- Test 2

enter image description here

我有一些对象。每个对象都可以是孩子。在这些孩子中也可能是孩子等。

@edit:

好的,但循环怎么样?我不想这样做,因为孩子的孩子数量可以是无限的:

                        $(myArray).each(function() {
                            if ($(this).children.length > 0) {
                                $(this).children.each(function() {
                                    if ($(this).children.length > 0) {
                                        ...
                                        ...
                                        ...
                                    }
                                });
                            }
                        });

0 个答案:

没有答案
相关问题