(なしマウス)、私は、Webページ上のボタンのスタックを上下にスクロールする(タブに加えて)、矢印キーを使用できるようにする必要があります。jQueryでdivラップされた兄弟にフォーカスを設定するにはどうすればいいですか?原因私のコントロールを超えた要件に
私は、私のjQueryのセレクタは、もはや機能し、純粋な兄弟であるボタンでそれを行う方法を考え出していないが、私はdiv要素でこれらのボタンをラップする場合(縦それらをスタックします)。私は基本的に "私の親の次の兄弟の子供"のセレクターが必要です。私は何時間も壁に頭を打ち、これを理解できません。次の例では
あなたは下のボタンのいずれかにフォーカスを設定する場合は、矢印キーを使用すると、ボタンの間を移動できるようになります。ただし、上部のペアのボタンはdivで囲まれており、矢印キーはそこでは機能しません。
ヘルプ?
<!DOCTYPE html>
<html>
<head>
<base href="http://demos.telerik.com/kendo-ui/button/index">
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.913/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.913/styles/kendo.material.min.css" />
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.913/styles/kendo.material.mobile.min.css" />
<script src="https://kendo.cdn.telerik.com/2017.3.913/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2017.3.913/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div class="demo-section k-content">
<div>
<p>
This doesn't work with up/down arrow keys:
<div><button id="textButton1" tabIndex="0">Button 1</button></div>
<div><button id="textButton2" tabIndex="0">Button 2</button></div>
</p>
<p>
But this does:
<button id="textButton3" tabIndex="0">Button 3</button>
<button id="textButton4" tabIndex="0">Button 4</button>
</p>
</div>
<script>
$(document).ready(function() {
$("#textButton1").kendoButton();
$("#textButton2").kendoButton();
$("#textButton3").kendoButton();
$("#textButton4").kendoButton();
$(".k-button").width(350);
$(".k-button:first").focus();
});
document.addEventListener('keydown', function(event)
{
const key = event.key;
switch (key)
{
case "ArrowDown":
//alert('Down');
$(".k-button:focus").next().focus(); \t
break;
case "ArrowUp":
//alert('Up');
$(".k-button:focus").prev().focus(); \t
break;
}
});
</script>
<style>
.demo-section p {
margin: 0 0 30px;
line-height: 50px;
}
.k-button {
margin-bottom: 20px;
}
.k-button .k-icon {
float: right;
margin: 2px;
}
</style>
</div>
</body>
</html>
役に立てば幸い
私は簡単に(前方)TABキーを使用して、ボタンの間を移動することができるとShilft + TAB(後方)(? ?) – Johannes
私は知っています。矢印キーが同じことをするのはビジネス上の必要条件です。私はルールを作っていませんでした。 –