jquery Mobile End Tab Touch screen switching implementation effect _jquery

Source: Internet
Author: User

We use the mobile end can be touched by the touch screen gesture left and right to switch tab column, such as NetEase news, such as app column switch. We say that the tab generally by the navigation bar and the corresponding content of the tab, switch the navigation bar on the label at the same time the content will follow the switch. This article will be combined with examples to introduce a mobile End tab touch Switch effect.

We prepare a tab navigation #pagenavi, which contains tab navigation to switch the four navigation buttons, and then the main content of the switch #slider, here should be placed four Li and navigation buttons corresponding, content customization.

<div class= "Box-163css" > 
 <ul id= "Pagenavi" class= "page" > 
  <li><a href= "#" >css3</ a></li> 
   <li><a href= "#" >JAVASCRIPT</a></li> 
  <li><a href= "#" >PHP</a></li> 
  <li><a href= "#" >HTML5</a></li> 
 </ul> 
 <div id= "Slider" class= "swipe" > 
  <ul class= "box01_list" > 
  <li class= "li_list" > 
  ... 
  </li> 
  ...<!--Total 4 li--> 
  </ul> 
 </div> 
</div>

Of course, we also need to add CSS style to HTML, which is based on their own habits and preferences.

Because it is the mobile end of the application, we load Zepto.js, Zepto is small size jquery. Then you need to load the touch-screen slide plugin touchslider.js.

<script type= "Text/javascript" src= "js/zepto_min.js" ></script> 
<script type= "Text/javascript" Src= "Js/touchslider.js" ></script>

Next we directly call Touchslider, by setting the Binding tab, slide direction, speed, time and other information to achieve the content switch, please see detailed code:

 <script type= "Text/javascript" > var page= ' Pagenavi '; 
 var mslide= ' slider '; 
 var mtitle= ' Emtitle '; 
 
 Arrdiv = ' Arrdiv '; 
 
 var As=document.getelementbyid (page). getElementsByTagName (' a '); var tt=new touchslider ({id:mslide, ' auto ': '-1 ', FX: ' Ease-out ', direction: ' Left ', speed:600,timeout:5000, ' before ': 
 function (index) {var As=document.getelementbyid (this.page). getElementsByTagName (' a '); 
 As[this.p].classname= '; 
 As[index].classname= ' active '; 
 This.p=index; 
 var Txt=as[index].innertext; 
 $ ("#" +this.page). Parent (). Find ('. Emtitle '). Text (TXT);  
 var txturl=as[index].getattribute (' href '); 
 var turl=txturl.split (' # '); 
 $ ("#" +this.page). Parent (). Find ('. go_btn '). attr (' href ', turl[1]); 
 
 }}); 
 tt.page = page; 
 TT.P = 0; 
  for (Var i=0;i<as.length;i++) {(function () {var j=i; 
  AS[J].TT = TT; 
  As[j].onclick=function () {this.tt.slide (j); 
  return false; 
 } 
 })(); } </script> 

The above is about mobile End Tab Touch Switch effect of the key code to share to everyone, I hope you like.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.