나는 mouseleave 이벤트가 있습니다. 내가 요소를 떠날 때, 나는 그 요소를 제거하지 않을 것입니다 (이것이 감각이라면). 아래 예제와 내가 시도한 것. 나는 그것이 그렇게 작동하지 않는다고 생각한다. (나는 짐작할 만하다.) 그러나 그것을하기위한 튼튼한 방법은 무엇인가? ATM.leaved의 요소를 제거하십시오
$('#wrapper').remove()
오히려
나는 mouseleave 이벤트가 있습니다. 내가 요소를 떠날 때, 나는 그 요소를 제거하지 않을 것입니다 (이것이 감각이라면). 아래 예제와 내가 시도한 것. 나는 그것이 그렇게 작동하지 않는다고 생각한다. (나는 짐작할 만하다.) 그러나 그것을하기위한 튼튼한 방법은 무엇인가? ATM.leaved의 요소를 제거하십시오
$('#wrapper').remove()
오히려
remove()
$(document).on('mouseleave', '#wrapper', function(e) {
console.log($(this).remove);
alert('Mouse leaved and wrapper should be removed');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="wrapper">asdcasdcasd</div>
$(document).on('mouseleave', '#wrapper', function(e) {
console.log($(this).remove());
alert('Mouse leaved and wrapper should be removed');
});
보다 방법이 아니다 속성입니다 : 나는 같은 선택을 사용할 수 없습니다. 사용
remove()
하지
remove
$(document).on('mouseleave', '#wrapper', function(e) {
console.log($(this).remove());
alert('Mouse leaved and wrapper should be removed');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="wrapper">asdcasdcasd</div>
귀하의 코드가 단지 조각, 당신은'당신이 당신의 처음 두 섹션에 나열했습니다 .remove()를'사용할 때 작동하지만' .remove'. – Herohtar