Question

How do I target a div that is dynamically created on mousedown and mousemove and then removed on mouseup?

I have tried to target it like so:

$ ('div').on('remove', '.ui-draggable-dragging', function(e){
      console.log('hello world');
    });

This div only happens when a box is created by another js script. Thanks for your help.

Was it helpful?

Solution

try this. If .ui-draggable-dragging is dynamically created you need to search the body for it before doing anything:

$('body').on('remove', '.ui-draggable-dragging', function (e) {
    console.log('hello world');
});

OTHER TIPS

You should try to inspect change on a higher element in the DOM like

$('body').on( 'change', '#container', function() {
   dowhatyouneed();
}):
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top