首页 > 代码库 > 获取页面内容封装成json对象

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

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对象