//上移
function sy(){
$('input[name = choiceds]:checked').each(function(i,n){
var ss = $('input[name = choiceds]:checked').length;
var now = $(this).parent('li');
var before = now.prev();
$(before).before(now);
});
}
//下移
function xy(){
$('input[name = choiceds]:checked').each(function(i,n){
var ss = $('input[name = choiceds]:checked').length;
var now = $(this).parent('li');
var after = now.next();
for(var i=1;i<ss;i++){
after = after.next();
}
$(after).after(now);
});
}
//置顶
function goTop(){
$('input[name = choiceds]:checked').each(function(i,n){
var now = $(this).parent('li');
var before = now.prev();
var first = $("#kkchoicedd ul").children(":first");
if(before.length>0){
$(first).before(now);
}
});
}
//置底
function goBtm(){
$('input[name = choiceds]:checked').each(function(i,n){
var now = $(this).parent('li');
var next = now.next();
var last = $("#kkchoicedd ul").children(":last");
if(next.length>0){
$(last).after(now);
}
});
}
------解决思路----------------------
你可以利用OO的思想封装下,类似于这样:
Swicther = (function(self,$){
self.up = function(){
}
self.down = function(){
}
self.top = function(){
}
self.bottom = function(){
}
function switchPosition(){
//doing common stuff
}
}(Swicther,JQuery.noConflict()));