I’m currently trying to select the previous closest list element within an <ul>
My current method works if there is > 1 <li> inside of it.
html:
<ul id="coaches" class="list">
<li><span>bob<a class="close"></a></span></li>
<li class="colored"><span>cobb<a class="close"></a></span></li>
</ul>
js:
$(this).closest("li").fadeOut("normal", function() {
$(this).remove();
});
How can I make it delete the previous closest list element with both the number of list element = 1 and > 1 elements? I tried adding a prev() and prevAll() chained after closest('li') but to no avail. Any ideas?
It should work as you have it in your example..
demo at http://jsfiddle.net/gaby/nZXxD/ for the code as it currently is
demo at http://jsfiddle.net/gaby/nZXxD/1/ for the code with a single
lielement..The problem must lie somewhere else..
(are you sure the event is bound correctly? and after the DOM is ready ?)