这是数据格式,求助。parent_id为零的为父级。
[
{
"id": 1,
"title": "餐饮美食",
"parent_id": 0,
"sort": 1
},
{
"id": 2,
"title": "丽人美发",
"parent_id": 0,
"sort": 1
},
{
"id": 3,
"title": "KTV酒店",
"parent_id": 0,
"sort": 1
},
{
"id": 4,
"title": "啊三大的",
"parent_id": 0,
"sort": 1
},
{
"id": 5,
"title": "休闲娱乐",
"parent_id": 0,
"sort": 1
},
{
"id": 6,
"title": "自助火锅",
"parent_id": 0,
"sort": 1
},
{
"id": 7,
"title": "玩",
"parent_id": 0,
"sort": 1
},
{
"id": 8,
"title": "餐饮吧",
"parent_id": 1,
"sort": 2
},
{
"id": 9,
"title": "剪发吧·",
"parent_id": 2,
"sort": 2
},
{
"id": 10,
"title": "ktv哦",
"parent_id": 3,
"sort": 2
},
{
"id": 11,
"title": "啊飒飒色彩哦",
"parent_id": 4,
"sort": 2
},
{
"id": 12,
"title": "休闲养生",
"parent_id": 5,
"sort": 2
},
{
"id": 13,
"title": "火锅·海底捞",
"parent_id": 6,
"sort": 2
},
{
"id": 14,
"title": "电影",
"parent_id": 7,
"sort": 2
},
{
"id": 15,
"title": "美食1",
"parent_id": 1,
"sort": 0
},
{
"id": 16,
"title": "美发2",
"parent_id": 1,
"sort": 0
},
{
"id": 17,
"title": "美发3",
"parent_id": 1,
"sort": 0
},
{
"id": 18,
"title": "美发4",
"parent_id": 1,
"sort": 0
},
{
"id": 19,
"title": "美发5",
"parent_id": 2,
"sort": 0
},
{
"id": 20,
"title": "美发6",
"parent_id": 2,
"sort": 0
},
{
"id": 21,
"title": "美发7",
"parent_id": 2,
"sort": 0
},
{
"id": 23,
"title": "333",
"parent_id": 1,
"sort": 0
},
{
"id": 24,
"title": "xlh2",
"parent_id": 1,
"sort": 0
}
]
http://jsfiddle.net/7yvxantu/1/点击预览
想要这样的效果?给第一个select绑定change事件,然后更改第二个select的html就可以了。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。