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); } 

demo


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -