无法专注于Bootstrap Carousel中的输入字段

时间:2018-03-08 06:49:45

标签: javascript jquery html twitter-bootstrap

我无法专注于引导程序轮播中的任何input字段。

无论您点击多少次,input字段都无法集中注意力。

我甚至尝试将z-index提供给input字段,但它仍然无法集中注意力。

您可以通过运行下面的 代码段 来检查错误。



$(document).ready(function(){

$(".carousel").swipe({

  swipe: function(event, direction, distance, duration, fingerCount, fingerData) {

    if (direction == 'left') $(this).carousel('next');
    if (direction == 'right') $(this).carousel('prev');

  },
  allowPageScroll:"vertical"

});

});

.carousel-indicators {
  position: absolute !important;
  bottom: -100px !important;
}

.carousel-indicators li {
  background-color: green;
  border: 1px solid green !important;
}

.carousel-inner>.item>div {
  padding: 30px;
}

.carousel-inner>.item>div>div {
  text-align: center;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  
<div class="container" id="skill-builder">

    <div class="row">

      <div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
          <li data-target="#carousel-example-generic" data-slide-to="1"></li>
          <li data-target="#carousel-example-generic" data-slide-to="2"></li>
        </ol>
    
        <!-- Wrapper for slides -->
        <div class="carousel-inner" role="listbox">
          <div class="item active">
            <div>
              <p>In the diagram shown, assume the pulley is smooth and fixed and the ropes are massless. The mass of each block is marked on the block in the diagram. Assume . Find the magnitute of the acceleration of block M.</p>
              <div>
                <img src="./assets/questions/1-question.jpg" alt="">
              </div>
              <div>
                <input type="text" placeholder="Enter Answer" name="answer">
              </div>
              <div>
                <button>Confirm</button>
              </div>
            </div>
          </div>
          <div class="item">
            <div>
              <p>In the diagram shown, assume the pulley is smooth and fixed and the ropes are massless. The mass of each block is marked on the block in the diagram. Assume . Find the magnitute of the acceleration of block M.</p>
              <div><img src="./assets/questions/2-question.png" alt=""></div>
              <div>
                <input type="text" placeholder="Enter Answer" name="answer2">
              </div>
              <div>
                <button>Confirm</button>
              </div>
            </div>
          </div>
          <div class="item">
            <div>
              <p>In the diagram shown, assume the pulley is smooth and fixed and the ropes are massless. The mass of each block is marked on the block in the diagram. Assume . Find the magnitute of the acceleration of block M.</p>
              <div><img src="./assets/questions/1-question.jpg" alt=""></div>
            </div>
          </div>
        </div>
    
        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
    
    </div>

  </div>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.touchswipe/1.6.18/jquery.touchSwipe.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

Enable The Touch Slider in Touch Device Only    

$(document).ready(function() {
                if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                    $(".carousel").swipe({

                        swipe: function(event, direction, distance, duration, fingerCount, fingerData) {

                            if (direction == 'left') $(this).carousel('next');
                            if (direction == 'right') $(this).carousel('prev');

                        },
                        allowPageScroll: "vertical"

                    });
                }


            });

答案 1 :(得分:1)

touchSwipe 版本从1.6.18更改为1.6.4