jQuery next()函数有时会检测到错误的项目

时间:2018-08-22 11:06:00

标签: jquery next detect

我刚刚完成我的网站,仅使用手机浏览器即可找到此页面的问题。 http://easondesign.co/kayo/about-us/

该功能可以在任何桌面浏览器上很好地运行,但是当我使用iPhone Safari时,有时会出错。

我想这是next()的问题;函数,该函数将检测到下一个div超过两个或三个,而不是下一个。

有人可以帮我调试吗?谢谢!

$('.tl_next').click(function() {
  if ($('.tsli_wrap > div').last().hasClass('current')) {
    return false;
  } else {
    MoveVal += PlusMinus;;
    $('.tsli_wrap').css('transform', 'translate(0,-' + MoveVal + 'px)');
    $('.tsli_wrap > div.current')
      .removeClass('current')
      .next('div')
      .removeClass('sec')
      .addClass('current').after(function() {
        $('.tsli_wrap > div').removeClass('sec');
        $('.tsli_wrap > div.current').next().addClass('sec');
        $('.tsli_wrap > div.current').prev().addClass('sec');
      });
  }
});

$('.tl_prev').click(function() {
  if ($('.tsli_wrap > div').first().hasClass('current')) {
    return false;
  } else {
    MoveVal -= PlusMinus;;
    $('.tsli_wrap').css('transform', 'translate(0,-' + MoveVal + 'px)');
    $('.tsli_wrap > div.current')
      .removeClass('current')
      .prev('div')
      .removeClass('sec')
      .addClass('current').after(function() {
        $('.tsli_wrap > div').removeClass('sec');
        $('.tsli_wrap > div.current').next().addClass('sec');
        $('.tsli_wrap > div.current').prev().addClass('sec');
      });
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="tl_arrow">
  <div class="tl_prev">
    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 16.7 12.2" style="enable-background:new 0 0 16.7 12.2;" xml:space="preserve">
    						<polyline class="tl_line" points="1.9,10.8 8.4,2 14.8,10.8 "/>
    					</svg>
  </div>
  <div class="tl_next">
    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 16.7 12.2" style="enable-background:new 0 0 16.7 12.2;" xml:space="preserve">
    					<polyline class="tl_line" points="14.8,2 8.4,10.8 1.9,2 "/>
    					</svg>
  </div>
</div>
<div class="tl_slider">
  <div class="tsli_wrap">
    <div>
      <i></i>
      <span>2018</span>
      <p>The first successful exhibition in LAS VEGAS</p>
    </div>
    <div>
      <i></i>
      <span>2017</span>
      <p>The first successful exhibition in LAS VEGAS first successful exhibition</p>
    </div>
    <div>
      <i></i>
      <span>2016</span>
      <p>The first successful exhibition in LAS VEGAS</p>
    </div>
    <div>
      <i></i>
      <span>2015</span>
      <p>The first successful exhibition in LAS VEGAS</p>
    </div>
    <div>
      <i></i>
      <span>2014</span>
      <p>The first successful exhibition in LAS VEGAS</p>
    </div>
    <div>
      <i></i>
      <span>2013</span>
      <p>The first successful exhibition in LAS VEGAS</p>
    </div>
    <div>
      <i></i>
      <span>2012</span>
      <p>The first successful exhibition in LAS VEGAS</p>
    </div>
  </div>
</div>

0 个答案:

没有答案