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.

Était-ce utile?

La 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');
});

Autres conseils

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

$('body').on( 'change', '#container', function() {
   dowhatyouneed();
}):
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top