javascript - How to make array of values of objects -
<input name="hello">value1 <input name="hello">value2 <input name="hello">value3 <input name="hello">value4 var = getelementsbyname('hello')
now, how create array contains (value1,value2,value3,value4)?
i thought of using makearray, returns objects not values.
you can iterate on them, or use map.
var items = array.prototype.map.call(a, function(el){ return el.nextsibling.textcontent; });
demo
var items = []; (var i=0; i<a.length; i++) { items.push(a[i].nextsibling.textcontent); }
Comments
Post a Comment