MARKUP
<ul class="focus">
<li class="active"><a>Text 1</a></li>
<li><a>Text 2</a></li>
<li><a>Text 3</a></li>
<li><a>Text 4</a></li>
<li><a>Text 5</a></li>
<li><a>Text 6</a></li>
<li><a>Text 7</a></li>
<li><a>Text 8</a></li>
<li><a>Text 9</a></li>
<li><a>Text 10</a></li>
<li><a>Text 11</a></li>
<li><a>Text 12</a></li>
</ul>
CSS
.focus{
height:60px;
list-style-type:none;
overflow:auto;
}
.focus li a {
}
.focus li.active{
background:#f6f6f6;
}
JQUERY
$( ".focus" ).keydown(function() {
if ( KeyCode == 40 ) {
$(this).next(li).addClass('active').children(a).focus();
});
For the this markup i need to add a class active to the children li when a down arrow is pressed and the active li needs to get focused. I dont how to break the codes further can anyone explain. Thanks in advance.