So, I have an ajax call with async set to false to load content into a particular div. Among this content there is a button with id='cancelbtn. Problem is, if I call remove, it is not removed, even though the console prints the element correctly one line before. Weirdly, if I repeat the remove line a number of times, then it works 'as expected'. Any ideas? The code from the ajax call is:
$.ajax ({
url: 'contentincludingthecancelbtn.html',
async: false,
success: function(data){
$('#divCont').html(data);
console.log($('#cancelbtn'));
$('#cancelbtn').remove();
});
});
The button displays at the end. This used to be a direct load call (not working either) changed in order to try async:false but no luck.