jquery table 순환 데이터 추가

1250 단어 jquery
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script>
	<style type="text/css">
		
	</style>
	<script type="text/javascript">
		$(function(){
			var list = [{'age':10},{'age':20},{'age':30},{'age':40},{'age':50},{'age':60},{'age':70},{'age':80},{'age':90},{'age':00}];
			var trs=[];
			var tds =[];
			var trDom;
			for(var i=0;i<list.length;i++){
				if(i%4===0){
					trDom = $('<tr></tr>');
					$('<td>'+list[i].age+'</td>').appendTo(trDom);
					trs.push(trDom);
				}else{
					$('<td>'+list[i].age+'</td>').appendTo(trDom);
					trs.push(trDom);
				}
			}
			for(var j=0;j<trs.length;j++){
			
				$(trs[j]).appendTo($('#show'));
			}

		})
	</script>
</head>
<body>
	<table border="1" width="100%" height="100%" id="show">
	</table>
</body>
</html>

좋은 웹페이지 즐겨찾기