$(function(){
	console.log(11111111);
	var test = '<?php echo  json_encode($viaArr)?>'
	var obj = JSON.parse(test)


	obj = uniqueArr(obj)
	console.log(obj)

	var html = '';
	for(var i in obj){
		var text = obj[i]?obj[i]:'空';
		html += "<input type='checkbox' class='viaCheckbox' value='"+obj[i]+"' checked='checked' />"+text;
	}
	$("#viaContainer").html(html)
});


$("#viaContainer").change(function(){
	var obj = $(".viaCheckbox");
	var checkVal = []
	var checkAll = []
	for(var i in obj){
		if(obj[i].checked){
			checkVal.push(obj[i].value);
		}
		if(obj[i].value != undefined){
			checkAll.push(obj[i].value)
		}
	}
	console.log(checkVal);
	console.log(checkAll)

	for(var k in checkAll){

		var className = 'via-'+checkAll[k]
		if(checkVal.indexOf(checkAll[k])>-1){
			$("."+className).fadeIn();
		}else{
			$("."+className).fadeOut();
		}
	}
	
});
$(function(){
	console.log(11111111);
	var test = '<?php echo  json_encode($viaArr)?>'
	var obj = JSON.parse(test)


	obj = uniqueArr(obj)
	console.log(obj)

	var html = '';
	html += "<select name='viaCheckbox'>";
	html += "<option selected='selected' value=''>--渠道筛选--</option>";
	for(var i in obj){
		var text = obj[i]?obj[i]:'空';
		html += "<option class='viaCheckbox' value='"+obj[i]+"'>"+text+"</option>";
	}
	html += "</select>"
	$("#viaContainer").html(html)
});


$("#viaContainer").change(function(){
	var obj = $(".viaCheckbox");
	var checkVal = []
	var checkAll = []
	for(var i in obj){
		if(obj[i].selected){
			checkVal.push(obj[i].value);
		}
		if(obj[i].value != undefined){
			checkAll.push(obj[i].value)
		}
	}
	console.log(checkVal);
	console.log(checkAll);

	for(var k in checkAll){
		var className = 'via-'+checkAll[k]
		if(checkVal.indexOf(checkAll[k])>-1){
			$("."+className).fadeIn();
		}else{
			$("."+className).fadeOut();
		}
	}
});

发表评论

电子邮件地址不会被公开。 必填项已用*标注