html - Move table rows up and down - Jquery/Javascript -
can please tell me how move table rows , down through jquery/javascript.
i have table , each row radio button there in first td. onclicking up/down arrows selected rows should move up/down.
looking forward ideas...
first selected row:
var radio; // assuming there's 1 form in page, replace 0 whatever // , inputs have name 'radiogroupname' (var in document.forms[0].radiogroupname) { if (documents.forms[0].radiogroupname[i].checked) { radio = documents.forms[0].radiogroupname[i].parentnode.parentnode; break; } }
to shift up:
var prev = radio.previoussibling; var par = radio.parentnode; if (prev) { par.removechild(radio); par.insertbefore(radio, prev); }
to shift down:
var next = radio.nextsibling; var par = radio.parentnode; par.removechild(radio); if (next.nextsibling) par.insertbefore(radio, next.nextsibling); else par.appendchild(radio);
Comments
Post a Comment