Google trends Public Holidays Coupon Code Code Compiler

Dragging and dropping table rows in Javascript

Mar 17, 2019

Dragging and dropping table rows in Javascript

In this article I will show you how to implement drag and drop for HTML tables in Javascript. There are many articles/blogs on implementing drag and drop table row in Javascript and many excellent frameworks and libraries that provide you exactly you need.

how to re-order table rows in javascript. Table rows are different from other elements normally used for drag and drop such as list items or divs because they can’t be moved about in the same way. In this example we will use bootstrap for just make it better layout and use jquery ui for make sortable table row.

HTML Code:

<!DOCTYPE html>
    <title>Drag and Drop table rows in Javascript</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="">
    <script src=""></script>
    <script src=""></script>
    <div class="container">
        <h3 class="text-center">Drag and Drop table rows using Javascript</h3>
        <table class="table table-bordered">
            <tbody class="row_drag">
                <tr  id="1">
				<tr  id="2">
				<tr  id="3">
				<tr  id="4">
				<tr  id="5">

Javascript Code:

<script type="text/javascript">
    $( ".row_drag" ).sortable({
        delay: 100,
        stop: function() {
            var selectedRow = new Array();
            $('.row_drag>tr').each(function() {

Copyright 2024. All rights are reserved