JS 下拉框 显示隐藏

JS 下拉框 显示隐藏_第1张图片

$(document).ready(function(){
        var member_id = "$app->user->id;?>"; //用户身份
		var localStorageControl = "User:" + member_id + ":Control"; //防止撞库
		var obj=JSON.parse(localStorage.getItem(localStorageControl));
		$.each(obj,function(x,y){
			var LabelTemp  = obj[x];
			var Obj =  $("ul[data-lfl='"+LabelTemp+"']");
			Obj.children('li').show('1000');
		})
	});

	$(".list-ul").on("click",function(){
		var This = $(this); //当前对象
		var uniap = This.data('lfl'); //当前点击类型唯一编码
		var member_id = "$app->user->id;?>"; //用户身份
		var localStorageControl = "User:" + member_id + ":Control"; //防止撞库
		var OBJ = {}; //对象存储
		var Visible =  0; //库准确数量

		if (This.children('li').is(":visible")) { //检测是否显示
			This.children('li').hide('1000'); 
		}else{
			This.children('li').show('1000');
		}
		var LI = $(".list-ul"); //当前集群

		localStorage.setItem("control", "Smith");
		for (var i = 0; i <= LI.length - 1; i++) {
			if ($(LI[i]).children('li').is(":visible")) {
				
				OBJ[Visible] =$(LI[i]).data('lfl');//OBJ
				Visible++;

			};

		};
		var obj = JSON.stringify(OBJ); //转化为JSON字符串
		localStorage.removeItem(localStorageControl); //清空
		localStorage.setItem(localStorageControl, obj); //存储
		Visible = 0;
		OBJ.length = 0; //清空
		// console.info(OBJ);
		// console.log(uniap);

	})

你可能感兴趣的:(前端)