In this article we will learn jQueryUI. This is the first part of this article series. UI stand for User interface and it's used for creating user-interactive applications using jquery and Html.
Prerequisites
Basic Knowledge of:
- HTML
- Javascript
- Css
In this part we are going to learn about these jQuery UI methods:
- Draggable
- Resizable
- Sortable
- <script src="Scripts/jquery-1.10.2.js"></script>
- <script src="Scripts/jquery-ui.js"></script>
- <link href="Scripts/jquery-ui.css" rel="stylesheet" />
Now first we will learn the draggable method.
Add 3 divs for a demo of the draggable method and add a style to these divs.
- .div1{
- height:160px;
- width:80px;
- border:1px solid Blue;
- background-color:orange
- }
Add these divs in the body section of our page
- <div>
- <div id="dvi1" class="div1">
- <h5 style="text-align:center">Div1</h5>
- </div>
- <div id="dvi2" class="div1">
- <h5 style="text-align:center">Div2</h5>
- </div>
- <div id="dvi3" class="div1">
- <h5 style="text-align:center">Div3</h5>
- </div>
- </div>
Now add the following code in script tag in head section to make it draggable to these divs.
- <script>
- $(document).ready(function () {
- $("#dvi1,#dvi2,#dvi3").draggable();
- });
- </script>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <script src="Scripts/jquery-1.10.2.js"></script>
- <script src="Scripts/jquery-ui.js"></script>
- <link href="Scripts/jquery-ui.css" rel="stylesheet" />
- <script>
- $(document).ready(function () {
- $("#dvi1,#dvi2,#dvi3").draggable();
- });
- </script>
- <style>
- .div1 {
- height: 160px;
- width: 80px;
- border: 1px solid Blue;
- background-color: orange;
- }
- </style>
- </head>
- <body>
- <div>
- <div id="dvi1" class="div1">
- <h5 style="text-align:center">Div1</h5>
- </div>
- <div id="dvi2" class="div1">
- <h5 style="text-align:center">Div2</h5>
- </div>
- <div id="dvi3" class="div1">
- <h5 style="text-align:center">Div3</h5>
- </div>
- </div>
- </body>
- </html>
Run the project and check the draggable div. We can see the divs are draggable.


Sortable
- <!DOCTYPE html>
- <html>
- <head>
- <script src="Scripts/jquery-1.10.2.js"></script>
- <script src="Scripts/jquery-ui.js"></script>
- <link href="Scripts/jquery-ui.css" rel="stylesheet" />
- <script>
- $(document).ready(function () {
- $("#s1").sortable();
- });
- </script>
- <style>
- .d1{
- border:4px solid blue;
- padding:20px;width:50px;margin:10px;
- }
- </style>
- </head>
- <body>
- <div id="s1">
- <div class="d1">Jaipur</div>
- <div class="d1">Delhi</div>
- <div class="d1">Noida</div>
- <div class="d1">Gurgaon</div>
- <div class="d1">Ajmer</div>
- </div>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <script src="Scripts/jquery-1.10.2.js"></script>
- <script src="Scripts/jquery-ui.js"></script>
- <link href="Scripts/jquery-ui.css" rel="stylesheet" />
- <script>
- $(document).ready(function () {
- $("#dvi1,#dvi2").resizable();
- });
- </script>
- <style>
- .div1 {
- height: 160px;
- width: 80px;
- border: 1px solid Blue;
- background-color: orange;
- margin:10px;
- }
- </style>
- </head>
- <body>
- <div>
- <div id="dvi1" class="div1">
- <h5 style="text-align:center">Div1</h5>
- </div>
- <div id="dvi2" class="div1">
- <h5 style="text-align:center">Div2</h5>
- </div>
- </div>
- </body>
- </html>
Run the project and check the browser.


Join the conversation! Your thoughts help the community grow.