.appendTo()
MethodYou can use the jQuery .appendTo()
method to move an element into another element.
The selected element will be taken out completely from its old location in the DOM and inserted at the end of the target container. Let's try out the following example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Move a Div Element into Another Div</title>
<style>
.box{
padding: 20px;
background: #f0e68c;
}
.content{
padding: 20px;
margin: 30px 0;
border: 1px solid #333;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$(".content").appendTo("#target");
$(this).hide(); // Hide move button
});
});
</script>
</head>
<body>
<div id="target" class="box">
<h1>Target Container</h1>
</div>
<div class="content">
<h1>Hello World.</h1>
<p>Click the "Move" button to move this content block inside colored box.</p>
<button type="button">Move</button>
</div>
</body>
</html>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Generate QR Code using angularx-qrcode in Angular
This article is fixated on how to engend...How to Install FileZilla FTP client in Ubuntu
FileZilla is a open-source multi-platfor...Laravel 8 Paypal Payment Gateway Integration
Paypal is a international payment proces...Laravel Eloquent Many to Many Polymorphic Relationship Tutorial with Example
Laravel provides eloquent relationship w...How to install Oracle VirtualBox in Ubuntu
VirtualBox is the free and open-source s...