您的位置:首页 > Web前端 > JQuery

Jquery数据复制

2015-09-11 11:23 721 查看
function copyValue(src,target){

$(src).find("span").each(function(){

var span = this;

var srcName = $(span).attr("name");

if(srcName != undefined){

var text = $(span).text();

$(target).find("span").each(function(){

var targetName = $(this).attr("name");

if(srcName == targetName){

$(this).text(text);

}

})

}

});

$(src).find("input").each(function(){

var input = this;

var srcName = $(input).attr("name");

if(srcName != undefined){

$(target).find(":input").each(function(){

var targetName = $(this).attr("name");

var type = $(this).attr("type");

if(srcName == targetName && "boeLineId" != targetName){

if(type == 'checkbox' || type == 'radio'){

var checked = input.checked;

$(this).attr("checked",checked);

}else{

var value = $(input).val();

$(this).val(value);

}

}

});

}

});

$(src).find("select").each(function(){

var select = this;

var srcName = $(select).attr("name");

if(srcName != undefined){

$(target).find("select").each(function(){

var targetName = $(this).attr("name");

if(srcName == targetName){

var srcValue = $(select).val();

$(this).find("option").each(function(){

var targetValue = $(this).val();

if(srcValue == targetValue){

$(this).attr("selected",true);

}

});

}

});

}

});

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: