给定以下无序列表:
<ul class="nb">
<li class="home"><a href="index.html" class="current"><span class="displace">Home</span></a></li>
<li class="products"><a href="products.html" title="Products"><span class="displace">Products</span></a></li>
<li class="services"><a href="services.html" title="Services"><span class="displace">Services</span></a></li>
<li class="support"><a href="support.html" title="Support"><span class="displace">Support</span></a></li>
<li class="company"><a href="company.html" title="Company"><span class="displace">Company</span></a></li>
<li class="contact"><a href="contact.html" title="Contact"><span class="displace">Contact</span></a></li>
</ul>
你能告诉我为什么以下只选择第一个列表项:
var status = 'closed';
$('ul.nb li a').click(function(e){
e.preventDefault();
if ($status == 'closed'){
var li = $(this).closest('li');
var items = li.parent().children();
console.log(items.html());
}
});
预期结果是所有列表项的选择,控制台显示
<a href="index.html" class="current"><span class="displace">Home</span></a>
TIA