javascript - How do I extract the name from HTML collection? -


here's step through of javascript.

enter image description here

i have htmlcollection, want loop through , extract object id of fileuploadcontrol. how do it?

here's code, how proceed?

    function uploadimage(lnk) {     var row = lnk.parentnode.parentnode;     var rowindex = row.rowindex - 1;     var abc = row.cells[2].getelementsbytagname("input");     var arr = [].slice.call(abc); } 

this it:

abc.nameditem('fileuploadcontrol')  

but beware that:

different browsers behave differently when there more 1 elements matching string used index (or nameditem's argument). firefox 8 behaves specified in dom 2 , dom4, returning first matching element. webkit browsers , internet explorer in case return htmlcollection , opera returns nodelist of matching elements.

from here.

this means if in markup had this:

<div id='id'>foo</div> <div id='id'>bar</div> 

browsers behave differently when executing following code:

document.getelementsbytagname('div').nameditem('id')` 

firefox return htmlelement, while ie return htmlcollection.

to solve inconsistencies, apply function return same object.

retelement( abc.nameditem('id') ); 

which this:

var retelement = function(oelem) {   //firefox   if (oelem instanceof window.htmlelement)     return oelem;   //ie , webkit   if (oelem instanceof window.htmlcollection)     return oelem.item(0); }; 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -