キーボードのTABキーをクリックすると、開いているすべてのアクティブなhrefリンクをナビゲートできます。それらのURLをJavaScriptで読むことは可能ですか?タブキーを操作するJavaScript
例:あなたがして、アクティブリンクに得ることができます
<!-- note that not all browsers focus on links when Tab is pressed -->
<a href="http://example.com">Link</a>
<input type="text" placeholder="Some input" />
<a href="http://example.com">Another Link</a>
<textarea>...</textarea>
::次のHTMLを持っ
function checkTabPress(key_val) {
if (event.keyCode == 9) {
// Here read the active selected link.
}
}
'document.activeElement'を見て、現在フォーカスされている要素(存在する場合は' body')を取得します。あなたは '.nodeName.toUpperCase()===" a "'をチェックしてから '.href'プロパティを読むことができます – Ian
この質問を見てください(テストしませんでした)。 http://stackoverflow.com/questions/11277989/how-to-get-the-focused-element-with-jquery –
@Ian '.toLowerCase()'を意味しましたか? –