In JavaScript, the Array object has a set of such input nodes. assume that there is only one such node: & lt; input & nbsp; p & nbsp; value1 & nbsp; & gt; I want to get all the pid and value, organize an Array or object, and pass it to other functions var & nbsp; count & nbsp; new & nbsp; Ar js.
There is a group of such input nodes in the DOM, assuming there is only one:
I want to get all the pid and value, organize an array or object and pass it to other functions.
Var count = new Array ();
$ ('. Js_count'). each (function (){
Var input = $ (this );
Var pid = input. attr ('pid ');
Var val = input. attr ('value ');
Count [pid] = val;
});
Data = {
Count: count
};
But what I get from alert (count) is:, 1, which is produced at the moment of count [pid] = val;, pid = 3, but from count [0] to count [2], an undefined is generated. I replace new Array () with new Object () and it will be okay.
Is this an Array object feature?
------ Solution --------------------
Yes, it is the feature of the Array object.
Undefined subscript is added.