search
HomeWeb Front-endJS TutorialjQuery implements tab sliding switching menu with slide effect

This time I will bring you jQuery to implement a tab sliding switching menu with a slide effect. What are the precautions for jQuery to implement a tab sliding switching menu with a slide effect. The following is a practical case, let's take a look.

This is a very good TAB sliding switching effect, jQuery tab sliding switching style menu navigation bar with slideshow, click on the text above, and slide to the left or right below to switch, TAB option with animation effect Card.

The screenshot of the running effect is as follows:

The online demonstration address is as follows:

http://demo.jb51.net/js/2015 /jquery-flash-style-tab-cha-menu-codes/

The specific code is as follows:

nbsp;html>

<meta>
<title></title>
<script></script>
<script>
;(function( $ ){
 var $scrollTo = $.scrollTo = function( target, duration, settings ){
 $(window).scrollTo( target, duration, settings );
 };
 $scrollTo.defaults = {
 axis:&#39;xy&#39;,
 duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
 };
 $scrollTo.window = function( scope ){
 return $(window)._scrollable();
 };
 $.fn._scrollable = function(){
 return this.map(function(){
  var elem = this,
  isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), [&#39;iframe&#39;,&#39;#document&#39;,&#39;html&#39;,&#39;body&#39;] ) != -1;
  if( !isWin )
   return elem;
  var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
  return $.browser.safari || doc.compatMode == &#39;BackCompat&#39; ?
  doc.body : 
  doc.documentElement;
 });
 };
 $.fn.scrollTo = function( target, duration, settings ){
 if( typeof duration == &#39;object&#39; ){
  settings = duration;
  duration = 0;
 }
 if( typeof settings == &#39;function&#39; )
  settings = { onAfter:settings }; 
 if( target == &#39;max&#39; )
  target = 9e9;
 settings = $.extend( {}, $scrollTo.defaults, settings );
 duration = duration || settings.speed || settings.duration;
 settings.queue = settings.queue && settings.axis.length > 1;
 if( settings.queue )
  duration /= 2;
 settings.offset = both( settings.offset );
 settings.over = both( settings.over );
 return this._scrollable().each(function(){
  var elem = this,
  $elem = $(elem),
  targ = target, toff, attr = {},
  win = $elem.is(&#39;html,body&#39;);
  switch( typeof targ ){
  // A number will pass the regex
  case &#39;number&#39;:
  case &#39;string&#39;:
   if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){
   targ = both( targ );
   // We are done
   break;
   }
   // Relative selector, no break!
   targ = $(targ,this);
  case &#39;object&#39;:
   // DOMElement / jQuery
   if( targ.is || targ.style )
   // Get the real position of the target 
   toff = (targ = $(targ)).offset();
  }
  $.each( settings.axis.split(&#39;&#39;), function( i, axis ){
  var Pos = axis == &#39;x&#39; ? &#39;Left&#39; : &#39;Top&#39;,
   pos = Pos.toLowerCase(),
   key = &#39;scroll&#39; + Pos,
   old = elem[key],
   max = $scrollTo.max(elem, axis);
  if( toff ){// jQuery / DOMElement
   attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
   // If it&#39;s a dom element, reduce the margin
   if( settings.margin ){
   attr[key] -= parseInt(targ.css(&#39;margin&#39;+Pos)) || 0;
   attr[key] -= parseInt(targ.css(&#39;border&#39;+Pos+&#39;Width&#39;)) || 0;
   }
   attr[key] += settings.offset[pos] || 0;
   if( settings.over[pos] )
   // Scroll to a fraction of its width/height
   attr[key] += targ[axis==&#39;x&#39;?&#39;width&#39;:&#39;height&#39;]() * settings.over[pos];
  }else{ 
   var val = targ[pos];
   // Handle percentage values
   attr[key] = val.slice && val.slice(-1) == &#39;%&#39; ? 
   parseFloat(val) / 100 * max
   : val;
  }
  // Number or &#39;number&#39;
  if( /^\d+$/.test(attr[key]) )
   // Check the limits
   attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );
  // Queueing axes
  if( !i && settings.queue ){
   // Don&#39;t waste time animating, if there&#39;s no need.
   if( old != attr[key] )
   // Intermediate animation
   animate( settings.onAfterFirst );
   // Don&#39;t animate this axis again in the next iteration.
   delete attr[key];
  }
  });
  animate( settings.onAfter );  
  function animate( callback ){
  $elem.animate( attr, duration, settings.easing, callback && function(){
   callback.call(this, target, settings);
  });
  };
 }).end();
 };
 $scrollTo.max = function( elem, axis ){
 var Dim = axis == &#39;x&#39; ? &#39;Width&#39; : &#39;Height&#39;,
  scroll = &#39;scroll&#39;+Dim;
 if( !$(elem).is(&#39;html,body&#39;) )
  return elem[scroll] - $(elem)[Dim.toLowerCase()]();
 var size = &#39;client&#39; + Dim,
  html = elem.ownerDocument.documentElement,
  body = elem.ownerDocument.body;
 return Math.max( html[scroll], body[scroll] ) 
  - Math.min( html[size] , body[size] );
 };
 function both( val ){
 return typeof val == &#39;object&#39; ? val : { top:val, left:val };
 };
})( jQuery );
$(document).ready(function() { 
 $(&#39;#mask&#39;).css({&#39;height&#39;:$(&#39;#panel-1&#39;).height()}); 
 $(&#39;#panel&#39;).width(parseInt($(&#39;#mask&#39;).width() * $(&#39;#panel p&#39;).length));
 $(&#39;#panel p&#39;).width($(&#39;#mask&#39;).width());
 $(&#39;a[rel=panel]&#39;).click(function () {
 var panelheight = $($(this).attr(&#39;href&#39;)).height();
 $(&#39;a[rel=panel]&#39;).removeClass(&#39;selected&#39;);
 $(this).addClass(&#39;selected&#39;);
 $(&#39;#mask&#39;).animate({&#39;height&#39;:panelheight},{queue:false, duration:500});  
 $(&#39;#mask&#39;).scrollTo($(this).attr(&#39;href&#39;), 800); 
 return false;
 });
});
</script>
<style>
body {
 padding:0;
 margin:0 20px;
 background:#d2e0e5;
 font:12px arial;
}
#scroller-header a {
 text-decoration:none; 
 color:#867863; 
 padding:0 2px;
}
#scroller-header a:hover {
 text-decoration:none; 
 color:#4b412f
}
a.selected {
 text-decoration:underline !important; 
 color:#4b412f !important;
}
#scroller-header {
 background:url(images/header.gif) no-repeat;
 width:277px;
 height:24px;
 padding:35px 0 0 15px;
 font-weight:700;
}
#scroller-body {
 background:url(images/body.gif) no-repeat bottom center;
 width:277px;
 padding-bottom:30px;
}
#mask {
 width:250px;
 overflow:hidden;
 margin:0 auto;
}
#panel {
}
#panel p {
float:left;
}
#panel ul {
list-style:none;
margin:0 5px;
padding:0;
}
#panel ul li {
padding:5px;
color:#557482;
border-bottom:1px dotted #ccc;
}
#panel ul li.last {
border-bottom:none !important;
}
#panel-1 {
}
#panel-2 {
}
#panel-3 {
}
</style>


<h2 id="a-jQuery-Sidebar-Sliding-Tab-Menu-Tutorial-a"><a>jQuery Sidebar Sliding Tab Menu Tutorial</a></h2>
<p>
<a>流行时尚</a>
<a>网络注释</a>
<a>历史记录</a>
<a>网络收藏</a>
</p>
<p>
</p><p>
</p><p>
 </p><p>
 </p>
     
  • Simple JQuery Image Slide Show with Semi-Transparent Caption
  •  
  • A Really Simple jQuery Plugin Tutorial
  •  
  • Create a Simple CSS + Javascript Tooltip with jQuery
  •  
  • Simple jQuery Modal Window Tutorial
  •  
   

 

     
  • 30 Javascript Menu Plugins and Scripts
  •  
  • 10+ jQuery photo gallery and slider plugins
  •  
     

 

     
  • CSS and Web Gallery List
  •  
  • Examples for Inpiration
  •  
     

 

     
  • 脚本之家
  •  
  • seo
  •  
  • wordpress
  •  
    

The above is the detailed content of jQuery implements tab sliding switching menu with slide effect. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Node.js Streams with TypeScriptNode.js Streams with TypeScriptApr 30, 2025 am 08:22 AM

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

Python vs. JavaScript: Performance and Efficiency ConsiderationsPython vs. JavaScript: Performance and Efficiency ConsiderationsApr 30, 2025 am 12:08 AM

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

The Origins of JavaScript: Exploring Its Implementation LanguageThe Origins of JavaScript: Exploring Its Implementation LanguageApr 29, 2025 am 12:51 AM

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

Behind the Scenes: What Language Powers JavaScript?Behind the Scenes: What Language Powers JavaScript?Apr 28, 2025 am 12:01 AM

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The Future of Python and JavaScript: Trends and PredictionsThe Future of Python and JavaScript: Trends and PredictionsApr 27, 2025 am 12:21 AM

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Python vs. JavaScript: Development Environments and ToolsPython vs. JavaScript: Development Environments and ToolsApr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Is JavaScript Written in C? Examining the EvidenceIs JavaScript Written in C? Examining the EvidenceApr 25, 2025 am 12:15 AM

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript's Role: Making the Web Interactive and DynamicJavaScript's Role: Making the Web Interactive and DynamicApr 24, 2025 am 12:12 AM

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment