/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(document).ready( function () { buttonUp = "<a class='moveup' ><img src='img/go-up.png' /></a>"; buttonDown = "<a class='movedown' ><img src='img/go-down.png' /></a>"; buttonLeft = "<a class='moveleft' '><img src='img/go-previous.png' /></a>"; buttonRight = "<a class='moveright' '><img src='img/go-next.png' /></a>"; $('a.moveup').bind("click", Move.up); $('a.movedown').bind("click", Move.down); $('a.moveleft').bind("click", Move.left); $('a.moveright').bind("click", Move.right); }); Move = { left: function() { ThisNode = $("../..",this); OtherNode = $("../../../..",this); ThisNode.slideUp(100); ThisNode.slideDown(300); ThisNode.find(".icons").append(buttonRight).end(); ThisNode.find(".moveleft").remove().end(); ThisNode.find(".moveright").click(Move.right).end(); OtherNode.after(ThisNode); return false; }, right: function() { ThisNode = $("../..",this); if ( ThisNode.next().find("ul").size() ) { $("../..",this).next().find("ul/li:last").after($("../..",this)); } else { $("../..",this).next().append("<ul class='sortable sortable2'><li class='sortableitem'>foo</li></ul>"); /* nor works this one $("../..",this).next().append("<ul></ul>").append("<li></li>"); */ } ThisNode.find(".icons").append(buttonLeft).end(); ThisNode.find(".moveright").remove().end(); ThisNode.find(".moveleft").click(Move.left).end(); return false; }, down: function() { ThisNode = $("../..",this); OtherNode = $("../..",this).next(); ThisNode.hide(80); OtherNode.hide(200); ThisNode.before(OtherNode); ThisNode.show(200); OtherNode.show(300); return false; }, up: function() { ThisNode = $("../..",this); OtherNode = $("../..",this).prev(); ThisNode.hide(100); OtherNode.hide(300); ThisNode.after(OtherNode); ThisNode.show(300); OtherNode.show(400); return false; } }
URL: http://xcite-online.de/tests/jquery1/