html
<div name="problem_list" id="problem_list">
<div id="form_input">
<table class="table table-bordered">
<button type="button" onclick="delForm(this);">삭제</button>
<tr>
<td>각종 input</td>
</tr>
</table>
</div>
</div>
<a href="#none" onclick="addForm();"> 질문추가</a>
<div id="list_file_tag" class="sr-only">
<div id="form_input">
<table class="table table-bordered">
<button type="button" onclick="delForm(this);">삭제</button>
<tr>
<td>각종 input</td>
</tr>
</table>
</div>
</div>
script
function addForm() {
$('#problem_list').append($('#list_file_tag').html());
check_click();
}
function delForm(obj){
var div = $(obj).parent();
//console.log(div);
//라인 삭제
div.remove();
}
css
.sr-only{
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
1.기본 폼과 동일하게 보이지 않는 태그 폼을 생성해둔다.
2.추가 버튼시 폼 리스트에 태그 폼을 추가(append)한다.
3.삭제시 버튼 클릭시 폼을 제거한다.
'개발 > javascript' 카테고리의 다른 글
구글 마커 안나옴 Error InvalidValueError: setMap: not an instance of Map; and not an instance of StreetViewPanorama (0) | 2021.03.31 |
---|---|
페이지 접속시 자동으로 탭 클릭하고 지정 영역으로 스크롤 이동 (0) | 2021.03.11 |
facebook 링크 공유 javascript (0) | 2021.02.26 |
html display none script 컨트롤 (0) | 2021.01.19 |
javascript form reset 초기화 (0) | 2021.01.19 |
댓글