js 动态生成div并添加点击事件

/* 动态生成div */
	function creatDiv(){ 
		$.ajax({
	   	type: "POST",
	   	url: "GetGis.action",
	   	success: function(msg){
		  var obj = eval("(" + msg + ")");
		  for(var i=0;i"+"项目名称:"+obj[i].GName+"
"+"负责人:"+obj[i].GStaff+"
"+"小组成员:"+obj[i].GMumber+ "
"+"指导老师:"+obj[i].GTeacher+ "
"+"获奖单位:"+obj[i].GAschool;//为div输入内容 div.id =i; div.className="main"; var Gis=document.getElementById("Gis");//获取目的div层 Gis.appendChild(div); //click(obj[i].GId); div.onclick=(function(param){ debugger var GId=param.GId; return function(){ // alert(GId); top.showMDialog("作品详细信息","ToGisDetail.action?GId=" + GId,900,600); } })(obj[i]); }} });

 

你可能感兴趣的:(js)