For functional needs, I wrote a small method to obtain a collection of multiple tagname nodes. Similar to the effect of jQuery's $('iput,select,textarea','#form'), the nodes are returned in the order they are in the original document stream.
//Get the node array of the specified tag type Use case: GetTagNames ('input,select,textarea',document.getElementById('form'))
function GetTagNames(tagnames,parEl){
//The parent node is not defined and the default loop document
var parEl=parEl || document;
//Get the child nodes of the specified parent element
var all=parEl.getElementsByTagName('*');
//Store all qualified child nodes
var nodes=[];
//Convert the transferred tagname into a regular judgment
var reg=eval('/' tagnames.split(',').join('|') '/i');
/ / Loop, judge, store
for(var ii=0;ii
if(reg.test(all[ii].nodeName)){
nodes.push( all[ii]);
}
}
//Return
return nodes;
}