JQuery实现多级联动效果

JS代码

(function(){ .post("getItemCatList.action",null,function(data){ var str=""; . e a c h ( d a t a , f u n c t i o n ( i n d e x , i n f o ) s t r + ="" + i n f o [ n a m e ] + "" ; ) ("#c1").append(str); }) ("#c1").change(function(){               $("#c2").empty();               $.post("getItemCatList.action",{parentId:$(this).val()},function(data){                   var str="";                   $.each(data,function(index,info){                       str+=""+info['name']+"";                   })                   $("#c2").append(str);               })           }) ("#c2").change(function(){ ("#c3").empty(); .post("getItemCatList.action",{parentId: (this).val()},function(data){                   var str=""; .each(data,function(index,info){ str+=""+info['name']+""; }) $("#c3").append(str); }) }) })



一级菜单
未选择
   
二级菜单
未选择
   
三级菜单
未选择

Java代码
@Autowired
private ItemCatService itemCatService;

@RequestMapping("getItemCatList")
@ResponseBody
public List<TbItemCat> getItemCatList(@RequestParam(value = "parentId", defaultValue = "0") long parentId) {
    return itemCatService.getByParentId(parentId);
}

表:
表关系设计

发布了15 篇原创文章 · 获赞 2 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/chtjava/article/details/80993530