9、两个下拉列表中的选项变换

 

RealTimeHistory_LKJ_allOption --左边列表

RealTimeHistory_LKJ_selectOption--右边列表

// 右移
$(".RealTimeHistory_LKJ_rightMove").unbind("click").click(function () {
$.each($(".RealTimeHistory_LKJ_allOption option:selected"),function(i,item){
$(".RealTimeHistory_LKJ_allOption option[value='"+$(item).val()+"']").remove();
$(".RealTimeHistory_LKJ_selectOption").append("<option value='"+$(item).val()+"'>"+$(item).text()+"</option>");
});

});

// 左移
$(".RealTimeHistory_LKJ_leftMove").unbind("click").click(function () {
$.each($(".RealTimeHistory_LKJ_selectOption option:selected"),function(i,item){
$(".RealTimeHistory_LKJ_selectOption option[value='"+$(item).val()+"']").remove();
$(".RealTimeHistory_LKJ_allOption").append("<option value='"+$(item).val()+"'>"+$(item).text()+"</option>");
});
});

// 全部右移
$(".RealTimeHistory_LKJ_allRightMove").unbind("click").click(function () {
$.each($(".RealTimeHistory_LKJ_allOption option"),function(i,item){
$(".RealTimeHistory_LKJ_allOption option[value='"+$(item).val()+"']").remove();
$(".RealTimeHistory_LKJ_selectOption").append("<option value='"+$(item).val()+"'>"+$(item).text()+"</option>");
});
});

// 全部左移
$(".RealTimeHistory_LKJ_allLeftMove").unbind("click").click(function () {
$.each($(".RealTimeHistory_LKJ_selectOption option"),function(i,item){
$(".RealTimeHistory_LKJ_selectOption option[value='"+$(item).val()+"']").remove();
$(".RealTimeHistory_LKJ_allOption").append("<option value='"+$(item).val()+"'>"+$(item).text()+"</option>");
});
});

// 上移
$(".RealTimeHistory_LKJ_upMove").unbind("click").click(function () {
if($(".RealTimeHistory_LKJ_selectOption option:selected").length>0){
var selectIndex=$(".RealTimeHistory_LKJ_selectOption").get(0).selectedIndex;

if(selectIndex>0){
$('.RealTimeHistory_LKJ_selectOption option:selected').insertBefore($('.RealTimeHistory_LKJ_selectOption option:selected').prev('option'));
}else{
alert("此为第一项了。");
}
}else{
alert("请选择一项。。。");
}
});

// 下移
$(".RealTimeHistory_LKJ_downMove").unbind("click").click(function () {
if($(".RealTimeHistory_LKJ_selectOption option:selected").length>0){
var selectLength=$(".RealTimeHistory_LKJ_selectOption option").length;
var selectIndex=$(".RealTimeHistory_LKJ_selectOption").get(0).selectedIndex;
if(selectIndex<selectLength-1){
$('.RealTimeHistory_LKJ_selectOption option:selected').insertAfter($('.RealTimeHistory_LKJ_selectOption option:selected').next('option'));
}else{
alert("此为最后一项了。");
}
}else{
alert("请选择一项。。。");
}
});

posted @ 2014-11-04 17:44  陌*简曦  阅读(142)  评论(0编辑  收藏  举报