Bootstrap

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

/* 动态生成div */
	function creatDiv(){ 
		$.ajax({
	   	type: "POST",
	   	url: "GetGis.action",
	   	success: function(msg){
		  var obj = eval("(" + msg + ")");
		  for(var i=0;i<obj.length;i++){
		  var div = document.createElement("div");         
	      div.innerHTML ="<img src='login/images/loginForm2.png'>"+"<br/>"+"项目名称:"+obj[i].GName+"<br/>"+"负责人:"+obj[i].GStaff+"<br/>"+"小组成员:"+obj[i].GMumber+ "<br/>"+"指导老师:"+obj[i].GTeacher+ "<br/>"+"获奖单位:"+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]); 
				   	}}
				});
	  
<div title="块状展示" id="Gis">

 

;