삭제버튼 클릭시 페이드 아웃 실습을 하고있는데요
새로고침을 하면 사라지긴합니다.
<h4>서버에서 가져온 할일 리스트<h4>
<ul class="list-group">
<% for (var i = 0; i < posts.length; i++){ %>
<li class="list-group-item hi">
<p>글번호 : <%= posts[i]._id %></p>
<h4>할일 제목 : <%= posts[i].이름 %> <h4>
<h4>할일 마감날짜 : <%= posts[i].나이 %><h4>
<button type="button" class="btn btn-primary delete" data-id="<%= posts[i]._id %>">삭제</button>
</li>
<% } %>
</ul>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
$('.delete').click(function(e){
var 글번호 = e.target.dataset.id;
var 지금누른거 = $(this);
$.ajax({
method : 'DELETE',
url : '/delete',
data : { _id : 글번호 }
}).done(function(결과){
console.log('삭제성공했음');
지금누른거.parent('li').fadeOut();
console.log(지금누른거);
});
})
</script>
console로그로 '지금누른거' 변수를 출력해보면 아래와 같이 나오는데
무엇이 문제인지 알수 있을런지요??
S.fn.init [button.btn.btn-primary.delete]
0: button.btn.btn-primary.delete
length: 1
__proto__: Object(0)