如何在IE中访问节点类型常量 [英] How does one access the Node Type Constants in IE

查看:98
本文介绍了如何在IE中访问节点类型常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个节点,我需要注意的是一个元素(从调用node.previousSibling)。但是,我无法找到跨浏览器JavaScript方式来访问节点常量显示在 MDC 上。



在所有浏览器中,但IE Node.ELEMENT_NODE被定义。我尝试使用特定的节点实例,例如:

  e = $(#element_id)[0]; 
alert(ELEMENT_NODE:+ ELEMENT_NODE);

这在IE中也不起作用。那么IE的做法是什么呢?我只需要自己定义节点常量?

解决方案

Internet Explorer 8及更早版本不定义节点类型常量,所以你必须自己定义它们。另外,Internet Explorer 7及更早版本仅适用于支持类型1和3


I have a node that I'm note sure is an element (from calling node.previousSibling). However I am having trouble finding out the cross browser javascript way to access the Node constants shown on the MDC.

In all browsers but IE Node.ELEMENT_NODE is defined. I tried using a specific instance of node, e.g.:

e=$("#element_id")[0];
alert("ELEMENT_NODE: " + ELEMENT_NODE);

This does not work in IE either. So whats the IE way to do this? Do I just have to define the node constants myself?

解决方案

Internet Explorer 8 and earlier don't define the node type constants, so you would have to define them yourself. Additionally, Internet Explorer 7 and earlier only support types 1 and 3.

这篇关于如何在IE中访问节点类型常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆