move or cut div to another parent by jquery and remove in last position i dont want to copy i just want to cut appendTo not working after ajax complete pelase help
To move a div to another parent and remove it from the original position using jQuery, you can use the .appendTo() method along with the .remove() method. Here's an example:
// Move the div with id "myDiv" to another parent
$('#myDiv').appendTo('#newParent');
// Remove the div from the last position
$('#oldParent #myDiv').remove();
If you are using this code after an AJAX request and the .appendTo() method is not working, make sure that you are executing the code after the AJAX request is complete. You can use the .done() method to ensure that the code runs only when the AJAX request is finished. Here's an example:
$.ajax({
// AJAX settings
})
.done(function(response) {
// Move the div with id "myDiv" to another parent
$('#myDiv').appendTo('#newParent');
// Remove the div from the last position
$('#oldParent #myDiv').remove();
});
Make sure to replace #myDiv, #newParent, and #oldParent with the actual IDs or selectors of your elements
原文地址: https://www.cveoy.top/t/topic/isXd 著作权归作者所有。请勿转载和采集!