본문 바로가기
JS

JS - 페이지 새로고침 div 새로고침, 요소삭제

by 나는 코딩왕 2021. 2. 10.

동적테이블 생성 시 특정 테이블 div 부분을 새로고침 하기 

 

1. 페이지 새로고침 

<script>
	window.location.reload();
</script>

 

 

2. div 특정영역 새로고침

<script>
function refresh(){  
      $("#div의 id").load(window.location.href + "#div의 id");
}
</script>

 

 

3. 동적테이블 생성 시 특정영역 데이터 요소 삭제 .empty();

<script type="text/javascript">

	
	function notcie(msg) {
		 
        var json = msg.data;
        var data = JSON.parse(json);
        
		var batchcskilllist = data.batchcskilllist;

	    
	    
	    var skillstr = '<TBODY><TR>';
	    
	    //테이블 비우기
				$("#cskill > tbody").empty();  
				
		//cskill 동적테이블 
		
	    $.each(batchcskilllist , function(k,v){

	    	skillstr += '<TD>' + v.acd + '</TD><TD>' +
            			   v.split + '</TD><TD>'+
            			   v.class_gubun + '</TD><TD>'+
            			   v.inqueue + '</TD><TD>'+
				   v.onacd + '</TD><TD>'+
				   v.acdcalls + '</TD><TD>'+
            			   v.callsoffered + '</TD><TD>'+
            			   v.creation_date + '</TD>';
            			  
            skillstr += '</TR></TBODY>';
            
       });
		
		$("#cskill").append(skillstr);
		
		
	}
    
    	function cskill_click(){
        
		 $('#cskill').show();
	 }
</script>
    
<style>
  table {
    width: 100%;
    border-top: 1px solid #444444;
    border-collapse: collapse;
  }
  th, td {
    border-bottom: 1px solid #444444;
    padding: 10px;
    text-align: center;
  }
  th {
    background-color: #f5f5f5;
  }
  td {
    background-color: #f5f5f5;
  }
</style>
</head>

<div id="tree"></div>



<body>
	<div>
	<table id = "table">
			<thead>
			<th>테이블선택</th>
				<th><button id = "CSKILL" onclick="cskill_click();">CSKILL</button></th>
			</thead>	
		</table>
		
	</div>
	
	
	
	
	
	
	<div id ="ctilist"  width:1800px;">
		<table id = "cskill">
			<thead>
				<th>ACD</th>
				<th>SPLIT</th>
				<th>CLASS_GUBUN</th>
				<th>INQUEUE</th>
				<th>ONACD</th>
				<th>ACDCALLS</th>
				<th>CALLSOFFERED</th>
				<th>CREATION_DATE</th>
			</thead>	
		</table>
		
	</div>
</body>

 

댓글