如何调整空格键和回车只适用于第三个按钮,不适用于任何其他按钮
How to adjust the space bar and enter works only for third button and not for any other button?
https://jsfiddle.net/ffkwgddL/
我的代码中有三个按钮,第一个按钮,第二个按钮和第三个按钮。如果我单击第一个按钮(即介绍(,然后按空格键,它会再次像我单击第一按钮一样工作,但如果我单击了第一个按钮然后按了第三个,即单击以获取下一个内容,然后按了空格,它会像我单击第三按钮一样工作。我希望空格键和回车键只适用于第三个按钮,而不适用于任何其他按钮,很抱歉,我的小提琴看起来没有那么好,因为它只适用于陆地景观。
<body>
<div class="container" id="wrapper">
<div class="top">
<div class="heading">
<h1>Multiples</h1>
</div>
</div>
<div class="main-content">
<div class="content-left col-xs-3">
<div class="btns" role="group" aria-label="...">
<button class="btn btn-default .btn-lg text-break first-button">Introduction<br>
</button>
<br>
<button class="btn btn-default .btn-lg text-break second-button">Properties of Multiples</button>
</div>
</div>
<div class="content-right col-xs-9">
<div class="content-first-button">
<div class="button1_text1 well well-lg">A <b><i>multiple</i></b> is the product of the given numbers and some other counting numbers.</div>
<div class="button1_text2">
<div class="button1_text2_1"><b>e.g.-</b></div>
<div class="button1_text2_2"><br>
When we multiply the number by <b>1, 2, 3, 4 ....</b>and so on, </div>
<div class="button1_text2_3">We get multiples of that number.</div>
<div class="button1_text3"><b>Multiples of 3</b></div>
<center>
<div class="button1_text4">
<p class="abcd"><b>1  </b> x <b>  3</b>   = <b>   3</b></p>
<p><b>2  </b> x <b>  3</b>   = <b>   6</b></p>
<p><b>3  </b> x <b>  3</b>   = <b>   9</b></p>
<p class="abcde"><b>  4  </b> x <b>  3</b>   = <b>   12</b></p>
</div>
</center>
</div>
</div>
<div class="button2_text1"><b>Properties of Multiples</b></div>
<div class="button2_text2">
<ul class="fa-ul">
<li> <i class="fa fa-star" aria-hidden="true"></i> <b class="button2_text2_1">Every number is a multiple of itself</b> </li>
</ul>
<br>
<b class="button2_text2_2"><i>i.e.</i></b> <b class="button2_text2_3">1     x     15     =     15</b></div>
<br>
<div class="button2_text3">
<ul class="fa-ul">
<li> <i class="fa fa-star" aria-hidden="true"></i> <b class="button2_text3_1">The least multiple of a number is number itself</b> </li>
</ul>
<b class="button2_text3_2">1     x     15     =     15</b> <b class="button2_text3_3"><i>least multiple</i></b> <br>
<b class="button2_text3_4">2     x     15     =     30</b><br>
<b class="button2_text3_5">3     x     15     =     45</b><br>
<b class="button2_text3_6">4     x     15     =     60</b><br>
</div>
<div class="button3_text3_7 well well-lg"<b>Every multiple of a number is completely divisible by that number</b> </div>
<div class="button3_text3_8">
<ul class="fa-ul">
<li> <i class="fa fa-star" aria-hidden="true"></i><b class="abcdefg">Every number is a multiple of 1</b> </li>
</ul>
</div>
<div class="button3_text3_9">
<ul class="fa-ul">
<li> <i class="fa fa-star" aria-hidden="true"></i>
<div class="abcdef">There is no end to multiples of a number, hence there is no highest multiple of a number.</div>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="col-md-3 col-xs-3"></div>
<div class="col-md-3 col-xs-3"></div>
<div class="col-md-6 col-xs-6">
<button class="btn btn-default .btn-lg text-break third-button">Click to get next content</button>
</div>
</div>
</div>
<div id="warning-message"> this website is only viewable in landscape mode </div>
</body>
</html>
只需将$(".first-button").blur();
或$(this).blur();
添加到您的单击函数中,即可在按钮聚焦时取消聚焦(如按钮的单击事件(。示例:
$(".first-button").click(function(){
...all your code...
$(".first-button").blur(); //or '$(this).blur();' instead
setTimeout(function(){ $(".third-button").focus(); }, 3000);
}
查看此处的Fiddle
我只为first-button
做过,你也可以为第二个做同样的事情。
更新:由于你的third-button
需要一些时间来褪色,你可以添加一个大约3秒的setTimeout()
,然后把它集中在第三个。Fiddle更新的
相关文章:
- 在循环中添加addEventListener()只适用于最后一个按钮
- Phonegap 3.2.0 android应用程序后退按钮剪切仅适用于某些页面
- onclick适用于一个按钮,但不适用于'不要为别人工作
- jquery:$(input).keydown无法在单选按钮上设置处理程序,同样的代码也适用于文本
- 使j查询ajax调用既适用于页面加载,也适用于单击按钮
- CSS for JS 按钮适用于本地计算机,但不适用于服务器
- 我的加载更多功能适用于按钮单击,但它不适用于滚动
- 如何将横向按钮放置到 iframe(适用于所有浏览器)
- 移动菜单切换问题(onclick 仅适用于外部容器,不适用于按钮)
- AngularJS:ng-单击不起作用,适用于<按钮>
- 如何使更改事件适用于使用 replaceWith 添加的 html 的单选按钮
- jQuery sortable 仅适用于文档就绪,不适用于按钮
- 一个功能适用于多个按钮
- Javascript getElementById()适用于文本框,但不适用于;不能使用单选按钮或下拉选择器
- 动态按钮点击事件仅适用于最后一个按钮
- 试图创建一个带有删除每一行的按钮的表,但它只适用于一行(javascript)
- onclick事件仅适用于按钮,而不适用于与按钮一起使用的glyphicon
- 单选按钮上的无提示验证被忽略,而它只适用于相同表单html中的文本字段
- MDL模态按钮适用于一张卡,但不适用于其他卡
- 如何调整空格键和回车只适用于第三个按钮,不适用于任何其他按钮