js遍历赋值


			
个人账户状态 维护年限
${pz.nianling}年
//全选 、 反全选 function checkListAll() { var flag = $("#toppcheckbox22").is(':checked'); $(".needredcolorr input[id='checkboxx']").each(function(i) { if (!$(this).is(":disabled")) { var grzh = $(this).val(); if (flag) { $(this).prop('checked', true); $(this).attr('checked', true); // if(grzhs.indexOf(grzh)<0) { // grzhs.push(grzh); // } if(!grzhs[grzh]) { grzhs[grzh]="0"; } } else { $(this).prop('checked', false); $(this).removeAttr("checked"); // grzhs.remove(grzh); delete grzhs[grzh]; } } }); } //给td赋值 $(function () { $('.needredcolorr input[type="checkbox"]').each(function () { //获取tr 的Id : 针对每一个tr,该tr都有一个id属性,该属性的值为项目id var nl = grzhs[$(this).val()]; console.log(nl) if(nl) { if (nl != "0") { $(this).parents("tr").eq(0).find('.nianling').text(nl+ '年'); } } }) })

			

//checkbox反显
	$(function () {
		$('.needredcolorr input[type="checkbox"]').each(function () {
			var nl = grzhs[$(this).val()];
			if(nl){
				if(nl!="0"){
					$(this).parents("tr").eq(0).find("select").val(nl);
				}
			}
		})
	})
//选择人员 checkbox 显示删除

$("#example2 tbody tr").each(function() {
		$(this).find("td").not(":first").click(function() {
			// var $td = $(this).parents("tr").eq(0).find('.zjhm')
			// var zjhm = $td.text();
			// if($td.get(0) && !zjhm){
			// 	showMessage(2,"证件号码不能为空,请完善信息后再进行缴存!");
			// 	return false;
			// }
			var che = $(this).parents("tr").eq(0).find('#checkbox');
			var grzh = che.val();
			if (grzhs[grzh] == "0") {
				che.prop('checked', false)
				delete grzhs[grzh];//同时删除key和value
			} else {
				che.prop('checked', true)
				grzhs[grzh] = "0";
			}
		})
	})

这辈子坚持与不坚持都不可怕,怕的是独自走在坚持的道路上!!!

你可能感兴趣的:(浅谈前端,javascript)

个人账户状态 维护年限