Detect tag removed using jQuery

Problem: Want to detect a tag like <div>, when it removed, do something.

Solution: Based on this answer, we can use on’ to detect event like‘remove’:

keep in mind that you must add jQuery (v1.9.1 or above) and jQuery UI -(v1.10.2 or above) scripts in it.

For example, I want to detect a tag with class name “test”:

<div class="test">already to vanish</div>

in the jQuery script part, add below code:

$(".test").on("remove", function () {
    alert("Element was removed, do something");
})

You may also like...

Close Bitnami banner
Bitnami