.first('li) select first item in the list not working
<p>Hope you can help, this code is not working. It is selecting the next image ok, but if it is on the last image and there is no 'next image' then I want to select the first image in the 'li'. I've added an if condition: if (nextLi.value !=='')... but this doesn't seem to be working.</p>

<pre><code>    function nextImg(){         
    $('#background').find('img').animate({'opacity': 0}, 500, function (){
        var nextLi = $('.sel').parent().parent().next('li').find('a');

        if (nextLi.value !=='') {
            var nextLiA = nextLi.attr('rel');
            $('#background').find('img').attr({'src':nextLiA});
            $('.sel').appendTo(nextLi); 
        } else {
            var nextLi = $('.sel').parent().parent().first('li').find('a');
            var nextLiA = nextLi.attr('rel');
            $('#background').find('img').attr({'src':nextLiA});
            $('.sel').appendTo(nextLi); 
        }
    });
}
</code></pre>
