Hi how can i select and add a class to the prev and next a tag.
<div class="sub">
<ul>
<li><a href="#">a</a>
<ul>
<li><a href="#">b</a>
<ul>
<li><a href="#">c</a></li>
<li><a href="#">d</a></li>
<li><a href="#">e</a></li>
</ul>
</li>
<li><a href="#">f</a></li>
<li><a href="#">g</a></li>
</ul>
</li>
<li><a href="#">h</a></li>
<li><a href="#">i</a></li>
<li><a href="#">j</a></li>
</ul>
</div>
example:
now i want to add 2 css classes (.prev & .next) to the the according elements presume that the mouse is over the element <li><a href="#">g</a></li>
, so i want to add the 2 classes to <li><a href="#">f</a></li>
and <li><a href="#">h</a></li>
snip:
$(document).ready(function() {
$('li').css({'border-top': '1px solid green','border-bottom': '1px solid green'});
$('li a').each(
function(intIndex){
$(this).mouseover(function(){
$(this).css({'border-top': '1px solid red','border-bottom': '1px solid red'});
$(this).prev().find('li').css({'border-bottom': 'none'});
$(this).next().find('li').css({'border-top': 'none'});
}).mouseout(function(){
$(this).css({'border-top': '1px solid green','border-bottom': '1px solid green'});
});
}
);
});
thanks in advance