首页 > Web开发 > 详细

获取页面内容封装成json对象

时间:2017-07-17 16:37:42      阅读:241      评论:0      收藏:0      [点我收藏+]

function(params, dom){
  var courseName= document.getElementsByName("courseName");
  var teacherName = document.getElementsByName("teacherName");
  var courseId = document.getElementsByName("courseId");
  var courseList = [];
  for(var i=0; i< courseName.length; i++){
  if(courseId.length > i){
  var id = courseId[i].value;
  }
  else id = ‘‘;
  var course = { "id": id, "name":courseName[i].value,"teacherName":teacherName[i].value};
  courseList.push(course);
  }
  console.info(courseList);
  params.courseList = courseList;
  params = {data:JSON.stringify(params)};
  return params;
}

获取页面内容封装成json对象

原文:http://www.cnblogs.com/xiaolin-peter/p/7195992.html

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