Is nodeIndex a valid DOM element property in IE?

亡梦爱人 提交于 2019-12-11 10:38:58

问题


I came across some javascript at work today that used jQuery to fetch two elements. It then used elem.nodeIndex to determine the position in the elements parent for each element. Nothing is setting this property anywhere and I do now see a reference to it in the msdn, mdc, or anywhere else.

I stepped through this javascript in FireFox with FireBug and tested the code in chrome and opera. I am sure nothing was trying to set this property. However, I can't find any information on this nodeIndex property anywhere.

Does nodeIndex exist as a DOM property in IE, or did I miss something while debugging my code?

UPDATE: I asked the same question on the jQuery list and they confirmed the property is for internal use only.:


回答1:


It looks like it's jQuery that's adding nodeIndex to nodes in some cases.




回答2:


Well, the easy answer is: If it isn't documentated anywhere like MDC, MSDN or W3, then it isn't a 'real' DOM property.

The idea of using nodeIndex, is also wrong, why would you want to do that?



来源:https://stackoverflow.com/questions/1338721/is-nodeindex-a-valid-dom-element-property-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!