什么是this.parentElement? [英] What is this.parentElement?

查看:209
本文介绍了什么是this.parentElement?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pg.myfunc = function(){
    var i = 1, j = 2;
    this.selected = 1;
    xx.newObject = this.parentElement;

...

什么是 xx。 newObject = this.parentElement; 在做什么?

推荐答案

相同this.parentNode :它为您提供包含的节点作为childNode。 将是 pg ,可能是某种元素; this.parentNode 将包含它,或者文档对象,如果 pg 是根元素。

It's the same as this.parentNode: it gives you the node that contains this as a childNode. this will be pg, presumably an Element of some kind; this.parentNode will be the Element that contains it, or the document object if pg is the root element.

parentElement 是非标准 IE扩展。由于IE还支持标准属性 parentNode ,因此永远不应使用 parentElement

parentElement is a non-standard IE extension. Since IE also supports the standard property parentNode, parentElement should never be used.

或者,也许它只是一个具有名为 parentElement 属性的任意对象,在这种情况下它可以是任何东西。从该代码中找不到真正的方法,但在Element节点上设置 myfunc 等任意属性是不常见的。

Alternatively, maybe it's just an arbitrary object with a property called parentElement, in which case it could be anything at all. There's no real way to tell from that code, but it would be unusual to be setting arbitrary properties like myfunc on an Element node.

这篇关于什么是this.parentElement?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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