I'm able to change focus when the links are not wrapped in other elements.
This works:
HTML
<a id="first" href="#" class='move'>Link</a>
<a href="#" class='move'>Link</a>
<a href="#" class='move'>Link</a>
JS (with jQuery)
$(document).keydown(
function(e)
{
// Down key
if (e.keyCode == 40) {
$(".move:focus").next().focus();
}
// Up key
if (e.keyCode == 38) {
$(".move:focus").prev().focus();
}
}
);
But how do I achieve the same thing when the links are inside a list for example? Like this
<ul>
<li>
<a id="first" href="#" class='move'>Link</a>
</li>
<li>
<a href="#" class='move'>Link</a>
</li>
<li>
<a href="#" class='move'>Link</a>
</li>
</ul>