Since the 's are nested inside eachother, the parents are still being "hovered" when you hover over a child. To prevent all the parent links showing, you can loop through all the parent
's and hide the links for the parents. Also, use
.children()
to only select a direct child, not nested children.
$(document).ready(function(){
$('li').hover(
function(){
$(this).parents('li').each(function(){$(this).children('.editLink').hide();});
$(this).children('.editLink').show();
},
function(){
$(this).find('.editLink').hide();
}
);
});
Here is a working jsfiddle.