Tại sao bộ chọn :odd
không hoạt động khi tôi chuyển nó vào chức năng remove(selector)
? Theo số documentation, bộ lọc sẽ lọc bộ mục đã chọn trong trường hợp này là li
.Xóa bộ chọn không hoạt động
<ul id='list1'>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
</ul>
<ul id='list2'>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
</ul>
$(document).ready(function() {
$('#list1').children(':odd').remove(); // works as expected
$('#list2').children().remove(':odd'); // does not work
});
quả
-One
-Three
-One
-Two
-Three
-Four
[jsfiddle] (http://jsfiddle.net/nX8s2/) đã làm việc cho tôi. Tôi đang sử dụng phiên bản Chrome 26.0.1410.64 m –
@ ThomasC.G.deVilhena: Chuyển sang jQuery 1.9.1. – Blender
@Blender: Oh! Bây giờ tôi thấy. có vẻ như một lỗi ... +1 –