简体   繁体   English

用左右滑动标签

[英]sliding the tabs with left and right

  • I am new to js and jquery. 我是js和jquery的新手。
  • I have tabs code in that i included left and right arrow. 我有标签代码,我包括左右箭头。
  • If I select right arrow it show move to next tab with smooth slide. 如果我选择右箭头,则显示移动到具有平滑滑动的下一个选项卡。
  • If I select left arrow it show move to next tab with smooth slide. 如果我选择左箭头,则显示移动到具有平滑滑动的下一个选项卡。
  • even the tab contents should change. 甚至标签内容也应该改变。
  • can you guys tell me how to fix it. 你能告诉我如何解决它吗?
  • providing my code below. 在下面提供我的代码。

https://codepen.io/texirv/pen/MvXZQX?editors=1111 https://codepen.io/texirv/pen/MvXZQX?editors=1111

.right {
    transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
}

.left {
    transform: rotate(135deg);
    -webkit-transform: rotate(135deg);
}



  $('.left').click(function(){

    console.log("I am testing");

  })

You will need to find the current active tab and click on the next/prev tab based on the button clicked. 您需要找到当前活动选项卡,然后根据单击的按钮单击下一个/上一页选项卡。

Here is an example of the code you can use: 以下是您可以使用的代码示例:

  $('.left').click(function(){
    move('left');
  })
  $('.right').click(function(){
    move('right');
  })
  function move(to) {
    var current = $('li.current').index();
    var total = $('.tabs .tab-link').length;
    var add;
    switch (to) {
      case 'left':
        add = -1;
        break;
      case 'right':
        add = 1;
        break;
    }
    $('.tabs li.tab-link').eq((current+add)%total).click();
  }

This is the update based on your codepen: 这是基于您的codepen的更新:
https://codepen.io/anon/pen/XaYGRM https://codepen.io/anon/pen/XaYGRM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM