My Name is Kay....

DIY , 먹방 , 개발 , 육아 , 여행 좋아합니다.
AdBlock 사용시 화면이 정상적으로 노출되지 않습니다.
포스팅 관련 문의 및 개발 문의는 Email : wkzkfmxksi@gmail.com

추가 포스팅이 이뤄지지 않는 블로그입니다. 문의는 wkzkfmxksi@gmail.com 으로 연락주세요.
kay
조회 수 21281 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

관리자 페이지등에서 잊을만 하면 사용하는 기능인데..

그간 샘플링이 안되어서 매번 그때 그때 커스터마이징해서 썻던것인데 정리해보았습니다.


Test Url : http://www.uhoon.co.kr/test/2541.html


<!DOCTYPE html>
<html>
<head>
	<title>테이블에 동적으로 TR 추가 /삭제 하기</title>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8">
	<script src="http://code.jquery.com/jquery-latest.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#btnAddRow").on("click",function() {
				// clone
				$.trClone = $("#memberTable tr:last").clone().html();
				$.newTr = $("<tr>"+$.trClone+"</tr>");

				// append
				$("#memberTable").append($.newTr);

				// delete Button 추가
				$.btnDelete = $(document.createElement("input"));
				$.btnDelete.attr({
					name : "btnRemove",
					type : "button" ,
					value : "삭제"
				});
				$("#memberTable tr:last td:last").html("");
				$("#memberTable tr:last td:last").append($.btnDelete);

				// 버튼에 클릭 이벤트 추가
				$("#memberTable tr>td:last>input[type='button']").on('click', function(){
					$(this).parent().parent().remove();
				});
			});

			// 초기화
			$("#tableReset").on("click",function(){ 
				$("#frmTest").each(function(){ this.reset(); });

				$("input[name='btnRemove']").each(function () {
					$(this).trigger('click');
				});
			});
		});
	</script>
</head>

<body >
<div style="width:500px;text-align:right;">
	<input type="button" value="행추가"  id="btnAddRow" />
	<input type="button" value="reset" id="tableReset"/>
</div>
<br/>
<form method="post" id="frmTest">
<table id="memberTable" border="1" style="width:500px;">
	<tr>
		<td><input type="text" id="fullName" /></td>
		<td><input type="text" id="age"  /></td>
		<td><input type="text" id="addr" /></td>
		<td style="width:50px;"></td>
	</tr>
</table>
</form>
</body>
</html>




관련 게시물 

?

  1. woothemes FlexSlider - 슬라이더

    Date2014.09.16 CategoryUI Bykay Views286953
    Read More
  2. jQuery Plugin For Auto Resizing iFrame - iFrame Resizer

    Date2014.03.10 CategoryPlugIn Bykay Views105652
    Read More
  3. SelectBox Option 값 초기화 및 수정 삭제

    Date2013.03.02 CategoryUI Bykay Views36666
    Read More
  4. fancyBox - 레이어팝업 (추천)

    Date2013.04.16 CategoryPlugIn Bykay Views32412
    Read More
  5. 에러 리포팅 , Ajax 디버깅 ( JS , ASP ) - 오류메시지 확인하기

    Date2013.03.08 Categoryetc Bykay Views30638
    Read More
  6. animate - 각종 애니메이션 효과

    Date2013.04.11 CategoryUI Bykay Views26330
    Read More
  7. CheckBox 값 읽어오기

    Date2013.05.06 CategoryA to Z Bykay Views25268
    Read More
  8. Table에 동적 Tr 추가/삭제 하기

    Date2014.02.09 Categoryetc Bykay Views21281
    Read More
  9. jquery-syaku.rolling 상하좌우 롤링 ( 자동롤링 , 버튼 )

    Date2014.02.09 CategoryPlugIn Bykay Views20164
    Read More
  10. 스크롤 탑 컨트롤 - scrolltop control

    Date2013.05.29 CategoryUI Bykay Views18965
    Read More
  11. makisu - 메뉴 접기(?)

    Date2013.04.16 CategoryPlugIn Bykay Views18446
    Read More
  12. tiptip - 툴팁

    Date2013.04.14 CategoryPlugIn Bykay Views17886
    Read More
  13. jQuery Org Chart - 조직도 그리기

    Date2014.09.01 CategoryPlugIn Bykay Views16616
    Read More
  14. 자동 롤링 배너 Jquery

    Date2013.08.07 CategoryPlugIn Bykay Views13883
    Read More
  15. Star Rating Plugin - jQuery 별점 주기

    Date2014.05.01 CategoryPlugIn Bykay Views13225
    Read More
  16. Smooth Scroll - 스크롤 이동 ( 속도 , 위치 )

    Date2013.04.06 CategoryPlugIn Bykay Views12680
    Read More
  17. poshytip - 툴팁

    Date2013.04.15 CategoryPlugIn Bykay Views11803
    Read More
  18. 동적으로 추가된 객체에 datepicker() 적용하기

    Date2013.11.06 CategoryUI Bykay Views10142
    Read More
  19. 한글/영어 byte 체크해서 자르기

    Date2013.11.30 Categoryetc Bykay Views9704
    Read More
  20. select Box option ( 초기화,추가,삭제 )

    Date2013.04.03 CategoryUI Bykay Views9533
    Read More
Board Pagination Prev 1 2 3 Next
/ 3