Modify ↓
Ticket #4118 (closed bug: invalid)
jQuery.merge() resulting length property is incorrect
| Reported by: | jbeckton | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3.1 |
| Component: | unfiled | Version: | 1.3.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I am using merge to join two arrays of DOM objects together. The resulting array has all the items in it but the length property is not being updated.
var formOne = jQuery("#form1 > input"); //returns 3 items
var formTwo = jQuery("#form2 > input"); //returns 4 items
var fields = jQuery.merge( formOne, formTwo );
console.log(fields); // shows Object length = 3 but if
//I inspect the array further I see 7 elements in the array.
Attachments
Change History
Changed 4 years ago by jbeckton
-
attachment
jQueryMerge.gif
added
comment:1 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
http://docs.jquery.com/Utilities/jQuery.merge#firstsecond
Merge expects its first argument to be a real Array, which will automagically maintain a correct length property. You could use this instead:
jQuery("#form1 > input").add("#form2 > input");
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

screen shots of Firebug debug