简体   繁体   English

Bootstrap传送带幻灯片中的空格键已禁用

[英]Space Key Disabled in Form in Bootstrap Carousel Slide

I have a form inside a Bootstrap carousel slide. 我在Bootstrap轮播幻灯片中有一个表单。 I can not enter spaces in the text boxes in the fields and cannot see why. 我无法在字段的文本框中输入空格,也看不到原因。 Here's my code: 这是我的代码:

<section class="carousel slide" data-ride="carousel" data-interval="false" data-wrap="false">
  <div class="carousel-inner" role="listbox">
    <div class="item active">
        <form class="form-inline" name="myForm">
            <div class="form-group">
                <input name="title" type="text" class="form-control" /> 
            </div>
            <button type="submit" class="btn btn-success btn-link">Submit</button>
        </form>
    </div>
  </div>

</section>

You can capture the spacebar keypress (code 32) and prevent the propagation to the carousel. 您可以捕获空格键的按键(代码32)并防止传播到转盘。

$('input').on('keydown', function (e) {
  if (e.keyCode == 32) {
    e.stopPropagation();
  }
});

I would also prevent keyboard navigation on the carousel or people using the arrows might navigate through carousel slides. 我还可以防止在圆盘传送带上进行键盘导航,否则使用箭头的人可能会在圆盘传送带幻灯片中导航。

<section class="carousel slide" data-ride="carousel" data-interval="false" data-wrap="false" data-keyboard="false">

Live example: http://www.bootply.com/phVgpOYnO0 实时示例: http//www.bootply.com/phVgpOYnO0

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

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