zoukankan      html  css  js  c++  java
  • jq 二级筛选切换

    
    		<style type="text/css">
    			.content .miniNav{
    				    position: relative;
    				     100%;
    				    height: 120px;
    				    border-bottom: 1px solid #e5e5e5;
    				    background: transparent;
    				    z-index: 10;
    			}
    			.box{
    				height: 84px;
    				margin-top: 18px;
    				margin-bottom: 18px;
    			}
    			.box .ziliao,.box .ziliaoList{
    				height: 42px;
    			}
    			.box .des{
    				color: #aaa;
    				font-weight: 600;
    				 62px;
    				display: inline-block;
    				padding: 5px 6px;
    				margin: 5px 22px;
    			}
    			.box a{
    				cursor: pointer;
    				display: inline-block;
    				color: #333;
    				text-decoration: none;
    			}
    			.ziliao,.ziliaoList,.fiveLine{
    				font-size: 14px;
    			}
    			.box .item {
    				padding: 5px 6px;
    				margin: 5px 22px;
    				display: inline-block;
    				color: #333;
    				text-decoration: none;
    			}
    			.box .item--active {
    				border-radius: 2px;
    				color: #fff !important;
    				background: #fc2328;
    				box-shadow: 2px 2px 5px rgba(0, 0, 0, .05);
    			}
    		</style>
    
    
    		<div class="miniNav">
    			<!-- 筛选 -->
    			<div class="box">
    				<div class="ziliao">
    					<span class="des">全部资料</span>
    				</div>
    				<div class="ziliaoList">
    					<span class="des fenlei">资料分类</span>
    				</div>
    				<div class="fiveLine"></div>
    			</div>
    		</div>
    
    <script type="text/javascript">
    			//获取地址栏url
    			var URL = location.href
    			$.ajax({
    				url: 'http://www.xiaoma.com/channel_ajax.php?url=http://www.xiaoma.com/satpd/satyd/',
    				type: 'post',
    				data: {},
    				dataType: 'json'
    			}).then(function(res) {
    				//把从json获取的数据赋值给空数组
    				var str = ''
    				var str2 = ''
    				var str3 = ''
    				var defaultThirdId = res.defaultThirdId
    				var defaultFourId = res.defaultFourId
    				var defaultFiveId = res.defaultFiveId
    				//先判断该层是否有数据
    				if(res.thirdData.length!=0){
    				$.each(res.thirdData,function(index,element){
    				     if (element.id==defaultThirdId) {
    				     	 str +="<a class='item item--active'  href="+element['typedir']+">"+element['typename']+"</a>"
    				     } else{
    				     	 str +="<a class='item'  href="+element['typedir']+">"+element['typename']+"</a>"
    				     }
    				})
    				}
    				//先判断该层是否有数据
    				if(res.fourData.length!=0){
    				$.each(res.fourData,function(index,element){
    					if (element.id==defaultFourId) {
    						 str2 +="<a class='item item--active'  href="+element['typedir']+">"+element['typename']+"</a>"
    					} else{
    						 str2 +="<a class='item'  href="+element['typedir']+">"+element['typename']+"</a>"
    					}
    				})
    				}
    				if(res.fiveData.length!=0){
    				$.each(res.fiveData,function(index,element){
    						if (element.id==defaultFiveId) {
    							 str3 +="<a class='item item--active'  href="+element['typedir']+">"+element['typename']+"</a>"
    						} else{
    							 str3 +="<a class='item'  href="+element['typedir']+">"+element['typename']+"</a>"
    						}
    				})
    				}
    				//遍历完成之后挂上去
    				$('.ziliao').append(str)
    				$('.ziliaoList').append(str2)
    				$('.fiveLine').append(str3)
    			}).fail(function() {
    				console.log('获取数据失败');
    			})
    		</script>
    		
    
  • 相关阅读:
    数字雨-贪吃蛇
    C语言入门9-2-模块大致一览
    C语言入门9-1-分类函数
    C语言入门8-数组-基本算法
    C语言入门7-程序设计方法基础-循环结构
    C语言入门6-选择结构--f语句-switch
    C语言入门5-键盘的输入和屏幕输出
    C语言入门4-运算符和表达式
    C语言入门3-C语言概述及数据类型
    Systemd 入门教程:命令篇
  • 原文地址:https://www.cnblogs.com/heson/p/11791121.html
Copyright © 2011-2022 走看看