// Setup the "Move Me" links
$(".rowLink").click(function () {
// get the row containing this link
var row = $(this).closest("tr")
// find out in which table it resides
var table = $(this).closest("table")
// move it
row.detach()
if (table.is("#table1")) {
$("#table2").append(row)
} else {
$("#table1").append(row)
}
// draw the user's attention to it
row.fadeOut()
row.fadeIn()
})
// Setup the "Up" links
$(".rowUp").click(function () {
var row = $(this).closest("tr")
// Get the previous element in the DOM
var previous = row.prev()
// Check to see if it is a row
if (previous.is("tr")) {
// Move row above previous
row.detach()
previous.before(row)
// draw the user's attention to it
row.fadeOut()
row.fadeIn()
}
// else - already at the top
})
// Setup the "Up" links
$(".rowDown").click(function () {
var row = $(this).closest("tr")
// Get the previous element in the DOM
var next = row.next()
// Check to see if it is a row
if (next.is("tr")) {
// Move row above previous
row.detach()
next.after(row)
// draw the user's attention to it
row.fadeOut()
row.fadeIn()
}
// else - already at the bottom
})
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.