想做一个下拉菜单联动,后台给了一个json格式的URL。
不太会用,求指教。
[{"id":1,"majorname":"\u8ba1\u7b97\u673a","parentmajor":0,"hidden":0,"submajor":[{"id":2,"majorname":"\u67b6\u6784\u8bbe\u8ba1","parentmajor":1,"hidden":0},{"id":3,"majorname":"\u8f6f\u4ef6\u5f00\u53d1","parentmajor":1,"hidden":0},{"id":4,"majorname":"\u7f51\u7edc\u8fd0\u7ef4","parentmajor":1,"hidden":0},{"id":5,"majorname":"\u7535\u5b50\u5546\u52a1","parentmajor":1,"hidden":0}]},{"id":6,"majorname":"\u7ecf\u6d4e\u91d1\u878d","parentmajor":0,"hidden":0,"submajor":[{"id":7,"majorname":"\u5bf9\u5916\u7ecf\u6d4e\u8d38\u6613","parentmajor":6,"hidden":0}]}]
<div class="col-xs-12">
<label>专业</label>
<select class="selectpicker form-control" ></select>
</div>
写个伪代码
for item in items {
$('select').html(<option value="{item.id}">{item.majorname}</option>)
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。