1window.onload = function () {
2 var upLink = document.querySelectorAll(".up");
3
4 for (var i = 0; i < upLink.length; i++) {
5 upLink[i].addEventListener('click', function () {
6 var wrapper = this.parentElement;
7
8 if (wrapper.previousElementSibling)
9 wrapper.parentNode.insertBefore(wrapper, wrapper.previousElementSibling);
10 });
11 }
12
13 var downLink = document.querySelectorAll(".down");
14
15 for (var i = 0; i < downLink.length; i++) {
16 downLink[i].addEventListener('click', function () {
17 var wrapper = this.parentElement;
18
19 if (wrapper.nextElementSibling)
20 wrapper.parentNode.insertBefore(wrapper.nextElementSibling, wrapper);
21 });
22 }
23}