How To Move HTML Table Selected Row Up And Down In Javascript [ with Source code ]

In This Javascript Tutorial we will See How To Change Selected HTML Table Row Position Up Or Down On Button Click using JS And Netbeans Editor .

Subscribe :

Project Source Code:

<!DOCTYPE html>
        <title>HTML Table Row Up And Down</title>
        <meta charset="windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
            tr{cursor: pointer}
            .selected{background-color: red; color: #fff;font-weight: bold}
            button{margin-top:10px;background-color: #eee;border: 2px solid #00F;
                  color: #17bb1c;font-weight: bold;font-size: 25px;cursor: pointer}
        <table id="table" border="1">
                <th>First Name</th>
                <th>Last Name</th>
        <button onclick="upNdown('up');">&ShortUpArrow;</button>
        <button onclick="upNdown('down');">&ShortDownArrow;</button>
            var index;  // variable to set the selected row index
            function getSelectedRow()
                var table = document.getElementById("table");
                for(var i = 1; i < table.rows.length; i++)
                    table.rows[i].onclick = function()
                        // clear the selected from the previous selected row
                        // the first time index is undefined
                        if(typeof index !== "undefined"){
                        index = this.rowIndex;


            function upNdown(direction)
                var rows = document.getElementById("table").rows,
                    parent = rows[index].parentNode;
                 if(direction === "up")
                     if(index > 1){
                        parent.insertBefore(rows[index],rows[index - 1]);
                        // when the row go up the index will be equal to index - 1
                 if(direction === "down")
                     if(index < rows.length -1){
                        parent.insertBefore(rows[index + 1],rows[index]);
                        // when the row go down the index will be equal to index + 1

#js #javascript

What is GEEK

Buddha Community

How To Move HTML Table Selected Row Up And Down In Javascript [ with Source code ]
Lyda  White

Lyda White


How to Image Uploader with Preview || Html CSS JavaScript

Image Uploader with Preview || Html CSS JavaScript || #html #css #javascript #coding

#html #css #javascript 

code savvy

code savvy


Web Design Speed Code | HTML, CSS, JavaScript (GSAP) | Portfolio Design

Portfolio Website Design with HTML, CSS & Javascript


Hello Everyone, In this video we'll create a Portfolio Page design using HTML, CSS & JavaScript (GSAP) 📁

🧠 Knowledge : 

Html, CSS (Flexbox), JavaScript DOM, Javascript Animations.

Anyway, you can learn everything mentioned. Follow the tutorial.

⏱ Outline


#css #javascript  #JavaScript  #HTML #html 

Click to Watch Full Tutorial 

Anissa  Beier

Anissa Beier


HTML TABLE | Create a HTML TABLE Design | HTML & CSS TABLE With Source Code.

#htmltable #tablehtml #tablecss

HTML TABLE: Create a HTML TABLE Design | HTML TABLE With Source Code.

Source Code:

#html table #html #css

Lyda  White

Lyda White


Auto Typing Project with Html, CSS, JavaScript ||#code#codes#coding #css #js #html #typing

Auto Typing Project with Html, CSS, JavaScript ||#code#codes#coding #css #js #html #typing
Tags -
#coding #programming #programmer #developer #python #code #javascript #coder #computerscience #technology #codinglife #java #html #webdeveloper #tech #webdevelopment #css #software #webdesign #softwaredeveloper #programmers #linux #softwareengineer #php #programmingmemes #machinelearning #programminglife #codingisfun #development #bhfyp

#code #html #css #javascript

Rahul Jangid


What is JavaScript - Stackfindover - Blog

Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.

Who invented JavaScript?

JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.

What is JavaScript?

JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.

Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.

JavaScript Hello World Program

In JavaScript, ‘document.write‘ is used to represent a string on a browser.

<script type="text/javascript">
	document.write("Hello World!");

How to comment JavaScript code?

  • For single line comment in JavaScript we have to use // (double slashes)
  • For multiple line comments we have to use / * – – * /
<script type="text/javascript">

//single line comment

/* document.write("Hello"); */


Advantages and Disadvantages of JavaScript

#javascript #javascript code #javascript hello world #what is javascript #who invented javascript