In this video course i will teach you how to make draggable html elements using jquery & jquery UI
create index.html file inside your project and copy and base below code and run it
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Jquery UI </title>
<link href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" rel="stylesheet">
<style>
body{
background: #ccc;
overflow-x: hidden;
}
#draggable{
max-width: 200px;
border: 1px solid #ccc;
text-align: center;
padding:50px;
background: #fff;
font-family: sans-serif;
cursor: move;
}
</style>
</head>
<body>
<div id="draggable">
<h3>Hi , Please subscribe my channel.</h3>
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>
<script>
$(function() {
$("#draggable").draggable().delay(5000).show().fadeOut('slow');
});
</script>
</body>
</html>
first you have to copy and paste this code than we are add css and js file via jquery and jquery ui CDN files inside head section i am adding jquery ui css file from CDN
<link href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" rel="stylesheet">
thank before the body closing tag i am adding jquery & jquery UI file from CDN
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>
and than calling the jquery ui function draggable() like this
<script>
$(function() {
$("#draggable").draggable().delay(5000).show().fadeOut('slow');
});
</script>
if you want to learn more about draggable() you can visit official website of jquery UI here : https://jqueryui.com/draggable/
If you have problem to undertand you can watch my above video
i
Loading, please wait...