分享代码,共同进步!!!!(只是为了混口饭吃)
本人原则:别人已经实现的需求我们为什么还要重复造*呢?
功能需求截图
$(function(){
var payArray = new Array();
var recArray = new Array();
var $payAccNoSelect = $("#payAccNo");
var $recAccNoSelect = $("#recAccNo");
//备份payAccNoSelect的option集合
$("#payAccNo > option").each(function(){
payArray.push($(this).clone());
})
//备份recAccNoSelect的option集合
$("#recAccNo > option").each(function(){
recArray.push($(this).clone());
})
$payAccNoSelect.change(function(){
paySelected = $(this).find(":selected").val();
var recValue = $("#recAccNo").find(":selected").val();
$recAccNoSelect.empty();
for(var i = 0 ; i < recArray.length ; i++ ){
if(paySelected != recArray[i].val()){
$("#recAccNo").append(recArray[i]);
}
}
$recAccNoSelect.val(recValue);
})
$recAccNoSelect.change(function(){
recSelected = $(this).find(":selected").val();
var payValue = $payAccNoSelect.find(":selected").val();
$payAccNoSelect.empty();
for(var i = 0 ; i < payArray.length ; i++ ){
if(recSelected != payArray[i].val()){
$payAccNoSelect.append(payArray[i]);
}
}
$payAccNoSelect.val(payValue);
})
})