jquery ajax选项卡使用jQuery选项卡切换异步加载请求数据

jquery ajax选项卡使用jQuery选项卡切换异步加载请求数据

jquery ajax选项卡使用jQuery选项卡切换异步加载请求数据实现源码

淘建站为您提供更多_其它特效_Ajax_ajax_加载,在此特别感谢您对我们的支持与厚爱!

查看演示

演示不了,点击反馈

加入收藏

下载 491 次

打赏作者

觉得不错,可打赏下作者

下载资源

免费共享

特别说明:本站资源来自网友发布分享,仅供学习与参考,请勿用于商业用途,若有侵权请联系删除(272966172@qq.com)。
分类:其它特效 > Ajax 难易程度:入门级

$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */
	
	/* Defining an array with the tab text and AJAX pages: */
	var Tabs = {
		'Tab one'	: 'pages/page1.html',
		'Tab two'	: 'pages/page2.html',
		'Tab three'	: 'pages/page3.html',
		'Tab four'	: 'pages/page4.html'
	}
	
	/* The available colors for the tabs: */
	var colors = ['blue','green','red','orange'];
	
	/* The colors of the line above the tab when it is active: */
	var topLineColor = {
		blue:'lightblue',
		green:'lightgreen',
		red:'red',
		orange:'orange'
	}
	
	/* Looping through the Tabs object: */
	var z=0;
	$.each(Tabs,function(i,j){
		/* Sequentially creating the tabs and assigning a color from the array: */
		var tmp = $('<li><a href="#" class="tab '+colors[(z++%4)]+'">'+i+' <span class="left" /><span class="right" /></a></li>');
		
		/* Setting the page data for each hyperlink: */
		tmp.find('a').data('page',j);
		
		/* Adding the tab to the UL container: */
		$('ul.tabContainer').append(tmp);
	})

	/* Caching the tabs into a variable for better performance: */
	var the_tabs = $('.tab');
	
	the_tabs.click(function(e){
		/* "this" points to the clicked tab hyperlink: */
		var element = $(this);
		
		/* If it is currently active, return false and exit: */
		if(element.find('#overLine').length) return false;
		
		/* Detecting the color of the tab (it was added to the class attribute in the loop above): */
		var bg = element.attr('class').replace('tab ','');

		/* Removing the line: */
		$('#overLine').remove();
		
		/* Creating a new line with jQuery 1.4 by passing a second parameter: */
		$('<div>',{
			id:'overLine',
			css:{
				display:'none',
				width:element.outerWidth()-2,
				background:topLineColor[bg] || 'white'
			}}).appendTo(element).fadeIn('slow');
		
		/* Checking whether the AJAX fetched page has been cached: */
		
		if(!element.data('cache'))
		{	
			/* If no cache is present, show the gif preloader and run an AJAX request: */
			$('#contentHolder').html('<img src="img/ajax_preloader.gif" width="64" height="64" class="preloader" />');

			$.get(element.data('page'),function(msg){
				$('#contentHolder').html(msg);
				
				/* After page was received, add it to the cache for the current hyperlink: */
				element.data('cache',msg);
			});
		}
		else $('#contentHolder').html(element.data('cache'));
		
		e.preventDefault();
	})
	
	/* Emulating a click on the first tab so that the content area is not empty: */
	the_tabs.eq(0).click();
});
<div id="main">

<ul class="tabContainer">
<!-- The jQuery generated tabs go here -->
</ul>

<div class="clear"></div>

<div id="tabContent">
	<div id="contentHolder">
    	<!-- The AJAX fetched content goes here -->
    </div>
</div>

</div>

<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="js/script.js"></script>

声明:本资料由淘建站会员提供,如转载注明来源,资料来源淘建站免费素材库:https://www.taojz.cn/texiao/1122.html
jquery ajax选项卡使用jQuery选项卡切换异步加载请求数据 希望对你有帮助,感谢您的支持!
  • 无限加载瀑布流

    无限加载瀑布流

  • 原生JS瀑布流布局,无限加载

    原生JS瀑布流布局,无限加载

  • js简单瀑布流图片无限加载带鼠标悬停图片遮罩效果

    js简单瀑布流图片无限加载带鼠标悬停图片遮罩效果

  • html5全屏响应式图片瀑布流布局按钮切换特效

    html5全屏响应式图片瀑布流布局按钮切换特效

  • 可以无限加载的响应式瀑布流

    可以无限加载的响应式瀑布流

  • html5网格图片瀑布流布局加载动画特效

    html5网格图片瀑布流布局加载动画特效

  • 原生js简单瀑布流图片无限加载带鼠标悬停图片遮罩效果

    原生js简单瀑布流图片无限加载带鼠标悬停图片遮罩效果

  • jQuery css3响应式瀑布流图片无限加载代码

    jQuery css3响应式瀑布流图片无限加载代码

  • jQuery选项卡形式图片瀑布流布局选项卡切换效果代码

    jQuery选项卡形式图片瀑布流布局选项卡切换效果代码

  • 简单大气的瀑布流里带着tab选项卡切换效果源码下载

    简单大气的瀑布流里带着tab选项卡切换效果源码下载

  • jquery美女无限加载瀑布流效果

    jquery美女无限加载瀑布流效果

  • html5手机瀑布流图片加载效果

    html5手机瀑布流图片加载效果

  • 留言(0)
    头像
     阿里云限量代金券,戳我领取
    1 2