My Name is Kay....

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

추가 포스팅이 이뤄지지 않는 블로그입니다. 문의는 wkzkfmxksi@gmail.com 으로 연락주세요.
kay
조회 수 21279 추천 수 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. 특정 객체가 화면에 보이는지 여부 확인

    Date2015.12.14 CategoryUI Bykay Views4890
    Read More
  2. jQuery Formatnumber , 콤마처리

    Date2015.11.03 CategoryPlugIn Bykay Views2095
    Read More
  3. Select Box Option 동적 추가 , 삭제 , 복사

    Date2015.09.18 CategoryUI Bykay Views7081
    Read More
  4. FadeIn , FadeOut 을 이용한 간단한 메인 배너 이미지 노출.

    Date2014.10.23 Categoryetc Bykay Views2999
    Read More
  5. 기본값 가져오기 get default value

    Date2014.10.19 Categoryetc Bykay Views2323
    Read More
  6. woothemes FlexSlider - 슬라이더

    Date2014.09.16 CategoryUI Bykay Views286707
    Read More
  7. jQuery Org Chart - 조직도 그리기

    Date2014.09.01 CategoryPlugIn Bykay Views16611
    Read More
  8. Jquery Slider Bar / 슬라이더 바 3종 샘플

    Date2014.07.28 CategoryUI Bykay Views6713
    Read More
  9. 페이지 또는 객체에서 특정 키워드 강조하기

    Date2014.06.14 Categoryetc Bykay Views2716
    Read More
  10. Star Rating Plugin - jQuery 별점 주기

    Date2014.05.01 CategoryPlugIn Bykay Views13221
    Read More
  11. jQuery Plugin For Auto Resizing iFrame - iFrame Resizer

    Date2014.03.10 CategoryPlugIn Bykay Views105561
    Read More
  12. 우클릭 , 셀 선택 , 드래그 방지 스크립트

    Date2014.02.17 Categoryetc Bykay Views7916
    Read More
  13. Jquery Load 유무 체크하기

    Date2014.02.12 Categoryetc Bykay Views4287
    Read More
  14. jquery-syaku.rolling 상하좌우 롤링 ( 자동롤링 , 버튼 )

    Date2014.02.09 CategoryPlugIn Bykay Views20162
    Read More
  15. Table에 동적 Tr 추가/삭제 하기

    Date2014.02.09 Categoryetc Bykay Views21279
    Read More
  16. 한글/영어 byte 체크해서 자르기

    Date2013.11.30 Categoryetc Bykay Views9702
    Read More
  17. 동적으로 추가된 객체에 datepicker() 적용하기

    Date2013.11.06 CategoryUI Bykay Views10138
    Read More
  18. $.trim(str) trim...

    Date2013.10.16 Categoryetc Bykay Views3957
    Read More
  19. Jquery 로 defaultValue 읽어오기

    Date2013.10.03 CategoryA to Z Bykay Views3754
    Read More
  20. readonly , disabled 지정하기

    Date2013.10.01 CategoryA to Z Bykay Views4109
    Read More
Board Pagination Prev 1 2 3 Next
/ 3