티스토리 뷰
'폼 생성' 버튼을 클릭 시, '폼 삭제' 버튼을 포함한 양식이 생성된다.
각 양식에 포함되어있는 삭제 버튼 클릭 시, 새로 생성된 양식은 삭제가 되지 않는다.
function이 안먹힌다...
form을 생성하게 되면,
1 2 3 4 5 6 7 8 9 10 11 12 | //블럭 추가 $( '#add_block' ).on( "click" , function (){ if (btn_count >= 5){ alert( "등록은 최대 5개 까지 가능합니다" ); return ; } init(); btn_count++; if (btn_count > 1){ $( '.btn_del' ).first().removeAttr( "disabled" , "disabled" ); } }); |
삭제가 안된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //블럭 삭제 $(document).on( "click" , function (){ var thisIndex = $( '.btn_del' ).index($( this )); var thisRollText = $( '.rollNum' ).eq(thisIndex).text(); if (!confirm(thisRollText + " 삭제하시겠습니까?" )) { return ; } $( this ).parent().parent().remove(); btn_count --; if (btn_count == 1){ $( '.btn_del' ).first().attr( "disabled" , "disabled" ); } }); |
on("click", 뒤에 해당 클래스를 지정해주면 삭제가 가능하다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //블럭 삭제 $(document).on( "click" , ".btn_del" , function (){ var thisIndex = $( '.btn_del' ).index($( this )); var thisRollText = $( '.rollNum' ).eq(thisIndex).text(); if (!confirm(thisRollText + " 삭제하시겠습니까?" )) { return ; } $( this ).parent().parent().remove(); btn_count --; if (btn_count == 1){ $( '.btn_del' ).first().attr( "disabled" , "disabled" ); } }); |
'JavaScript & jQuery' 카테고리의 다른 글
jqGrid 리스트 출력 (1) | 2017.02.14 |
---|---|
mouseover, mouseout, mouseenter, mouseleave 차이점 (0) | 2016.11.14 |
Ajax 채팅, setInterval() (1) | 2016.11.14 |
jQuery color picker 사용법 (0) | 2016.10.18 |
ajax 파일 업로드 - Multipartparser (0) | 2016.10.12 |
최근에 올라온 글
최근에 달린 댓글
TAG
- ssl
- 제이쿼리
- trim
- mouseleave
- jqGrid
- fmt
- JQuery
- InputStream
- Spring
- mouseover
- return
- jquery filedownload
- 인코딩
- multipart/form-data
- Each
- ColorPicker
- httpurlconnection
- 프로시저
- poi
- mouseenter
- popup
- OutputStream
- opener
- mybatis
- c:foreach
- setInterval
- bootstrap
- mouseout
- CDN
- excel file download
- Total
- Today
- Yesterday