JS中的深度属性? [英] Depth Property in JS?

查看:250
本文介绍了JS中的深度属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说我有这个html代码:

lets say i have this html code :

<div>
 <a>
    <span id="a"> </span>
 </a>
</div>

我的问题:

有没有js 属性暴露元素的深度?

is there any js property which exposes element's depth ?

如下:

$("#a").prop ("depth") //3+3=6   +body+form+html   jquery selector is just for example.

p.s。我知道如何计算深度。我的问题是关于现有的财产。

p.s. i know how to calc the depth. my question is about existing property.

推荐答案


有没有任何js属性暴露元素的深度?

Is there any js property which exposes element's depth?

未内置,否。您可以随时使用 defineGetter defineSetter

Not built-in, no. You could always make one using defineGetter and defineSetter.

这篇关于JS中的深度属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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