dom - Are all HTML elements unique? -


i busy making javascript code allows me make gui page elements have custom context menus, when thought checking see if element exists in order make context menu it.

function element_exists(el){ var tagname=el.tagname; var exists=0; for(var a=0;a<document.getelementsbytagname(tagname).length;a++){     if(document.getelementsbytagname(tagname)[a]==el){         exists=1;     } } return exists; } 

in code, pass reference dom element object (which stored earlier). let's stored, since removed element document.

i'm using chrome canary, , if edit page through console , make new element exact same tag name , id, returns false. return true if had same innertext , innerhtml?

if not, standard in web browsers (old , new)? curious because eliminate unnecessary code if they're unique.

i'm pretty sure answer no; each element unique, regardless of whether have similar values (including "id").

this might provide insight how element garbage collection works in chrome. i'm not sure how other browsers respond though.

http://www.html5rocks.com/en/tutorials/memory/effectivemanagement/

it outlines tools might useful test theory.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -