首页 > 其他 > 详细

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

时间:2014-11-04 19:27:32      阅读:172      评论:0      收藏:0      [点我收藏+]

 

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("请选择一项。。。");
}
});

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

原文:http://www.cnblogs.com/danmohendt/p/4074295.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!