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);
}
});
}
});
}
});
}
$(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);
}
});
}
});
}
});
}
相关文章推荐
- jQuery中添加自定义或函数方法
- 在easyUI开发中,出现jquery.easyui.min.js函数库问题的解决办法
- Jquery方法load之后导致js失效解决方法
- Jquery跨域获得Json(实例)
- JQuery中Bind()事件用法分析
- JavaScript学习笔记8-jQuery入门介绍、css选择器复习
- jquery mobile
- jquery.validate使用攻略
- jquery中的ajax异步上传
- 《XMPP高级编程 使用JavaScript和jQuery》
- jQuery进行简单验证的正则表达式
- jQuery 实现checkBox全选效果
- jquery中的ajax同步和异步详解
- jquery在线手册,datatable(记录,防忘记)
- jQuery 获取屏幕高度、宽度
- 22款基于jQuery的响应式图片滑块插件
- MVC中使用Ajax提交数据 Jquery Ajax方法传值到action
- jQuery js 互转
- jquery 动态事件的监听(非live)
- JQuery中$.ajax()方法参数详解