我的 DOM 如下。
<html><head>...</head><body><script>...</script>
<iframe id="frame">
#document
<html>...</html> <!-- 2 -->
</iframe>
</body>
</html>
我正在 iframe
中绑定(bind)部分内容(即 html 2)。在 html_2 部分中,我正在调用 document.ready
使用 getElementById
获取 iframe
的 id
,但我得到空
。如何获取iframe
的id等属性值?
最佳答案
我这样做如下,
$("#iframe", parent.document).attr("id");
顺便说一句,感谢所有通过宝贵意见回答和帮助我的人。
关于javascript - 从父标签中通过 id 获取元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41157288/