jquery遍历的json有两层list时的解决方法

简介: //获取 学生分组列表function getStuList(){ $("#allMemberList").html(""); $.get("classTeam/queryClassTeamAndTeamMember/"+classId+"/0",function(result) { $.each(result.classTeamList,functio




//获取 学生分组列表
function getStuList(){
  $("#allMemberList").html("");
	$.get("classTeam/queryClassTeamAndTeamMember/"+classId+"/0",function(result) {
		$.each(result.classTeamList,function(k, v) {
			  $("#allMemberList").append(
					   '<div class="panel panel-default">'
					  +'	<div class="panel-heading">'+v.teamName+'</div>'
					  +'	<div class="panel-body">'
					  +'		<ul class="media-list user-list stuList">'+jsonson(v.id)
					  +'		</ul>'
					  +'	</div>'
					  +'    </div>'
					  +'</div>'
			  )
			  function jsonson(id){
			        var jsonHtml="";
			        $.each(result.classTeamList,function(k, v) {
			            if(id== v.id){
			                for(var i=0;i<v.tclassTeamMemberList.length; i++){
			                        jsonHtml+='<li class="media">'
										  +'	<div class="media-left">'
										  +'		<a href="javascript:;"><img class="media-object"'
										  +'			src="'+v.tclassTeamMemberList[i].user.userInfo.logo+'"></a>'
										  +'	</div>'
										  +'	<div class="media-body">'
										  +'		<h6 class="media-heading">'+v.tclassTeamMemberList[i].user.userInfo.ucName+'</h6>'
										  +'	</div>'
										  +'	<div class="close">'
										  +'		<span>×</span>'
										  +'	</div>'
										  +'</li>'	;
			                }
			            }
			        });
			        return jsonHtml;
			    }
		 })
	 })
}


目录
相关文章
|
3天前
|
JavaScript
jQuery 遍历 方法
jQuery 遍历 方法
16 5
|
23天前
|
JavaScript
jQuery 遍历
jQuery 遍历
24 2
jQuery 遍历
|
9天前
|
JavaScript
jQuery 遍历
jQuery 遍历
22 1
jQuery 遍历
|
7天前
|
JavaScript
jQuery 遍历 - 同胞(siblings)
jQuery 遍历 - 同胞(siblings)
16 6
|
8天前
|
JavaScript
jQuery 遍历 - 祖先
jQuery 遍历 - 祖先
25 5
|
7天前
|
JavaScript
jQuery 遍历- 过滤
jQuery 遍历- 过滤
13 2
|
18天前
|
JavaScript
jQuery 遍历 方法
jQuery 遍历 方法
23 3
|
22天前
|
JavaScript
jQuery 遍历 - 祖先
jQuery 遍历 - 祖先
13 4
|
22天前
|
JavaScript
jQuery 遍历 - 同胞(siblings)
jQuery 遍历 - 同胞(siblings)
18 2
|
22天前
|
JavaScript
jQuery 遍历 - 后代
jQuery 遍历 - 后代
14 2
下一篇
无影云桌面