Opened 10 years ago
Closed 10 years ago
#14000 closed bug (notabug)
jQuery.merge does not consider the nodelist
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 2.0.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
var list1 = document.querySelectorAll(".lists1 li"); //list1.length = 20 var list2 = $(".lists2 li"); //list2.length = 20 var result = $.merge(list1,list2); console.log(result.length); // it is 20,because the nodelist's length can't been modified
I think this situation is very common. Thanks!
Note: See
TracTickets for help on using
tickets.
Working as documented. http://api.jquery.com/jquery.merge/
A Nodelist is array-like but not an Array. This method is intended mainly for our internal use. We never call it with a Nodelist as the first arg.