JavaScript - Dynamic Image Reorder
Submitted by razormist on Thursday, March 21, 2019 - 21:09.
In this tutorial we will create a Dynamic Image Reorder using JavaScript. This code can move and reorder the object in any posiiton at the same time. It use jQuery-UI to implement the feature in order to rearrange the image order. This is a user-friendly program feel free to modify it.
We will use jQuery-UI as a curated set of user interface interactions that built in jQuery, a JavaScript Library that consist of different widgets. It is highly interactive web applications that just needed to add a widget to make a certain script works.
There you have it we successfully created a Dynamic Image Reorder using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Getting Started:
This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/. And this is the link for the jquery that i used in this tutorial https://jquery.com/. Lastly, this is the link for the jQuery-UI that I used https://jqueryui.com/.The Main Interface
This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- <link rel="stylesheet" type="text/css" href="css/jquery-ui.css"/>
- <style>
- #images {
- list-style-type: none;
- }
- #images li {
- margin:5px;
- float: left;
- width: 180px;
- height: 180px;
- font-size: 4em;
- text-align: center;
- cursor:pointer;
- }
- </style>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- </div>
- </nav>
- <div class="col-md-6 well">
- <hr style="border-top:1px dotted #ccc;"/>
- <ul id="images">
- </ul>
- </div>
- </body>
- </html>
Creating the Script
This code contains the script of the application. This code can reorder the image position by dragging. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js directory- $(document).ready(function(){
- $( "#images" ).sortable();
- $( "#images" ).disableSelection();
- });
Add new comment
- 420 views