阅读 79

jq复选框

image.png



<script src="https://s.umfun.com/view3/js/jquery-1.9.1.js?v=2015-09-29_16:12"></script>

<style type="text/css">
.child{margin:5px;padding:3px;border:1px solid blue;}
</style>
<div style="border:1px solid red;margin:10px;padding:10px;" id="main">

</div>

<script type="text/javascript">

function setHtml(data){
	var html='';
	for(var i in data){
		//console.log(data[i].subjectName);
		html+='<label class="child"><input type="checkbox" value="'+data[i].subjectType+'" />'+data[i].subjectName+'</label>';
	}
	$('#main').html(html);
}

function getData(){

	$.ajax({
		url:'http://119.23.113.71:9001/service-soa/count/getUnifiedSubjectType',
		type:'post',
		data:{requestJson:'{"interUser":"runLfb","interPwd":"d41d8cd98f00b204e9800998ecf8427e","operateAccountNo":27177,"belongSchoolId":24,"unifiedExaminationId":1001}'},
		dataType:'json',
		success:function(rs){
			console.log(rs);
			if(rs.flag){
				setHtml(rs.data);
			}else{
				alert(rs.msg);
			}
		},
		error:function(){
			alert('error');
		}
	
	})

}


getData();
</script>
复制代码
文章分类
前端
文章标签