在子页面获取父页面的id

JQ:

1,$("#id",parent.document)

2,$(window.parent.document).find("#id")

JS:

1,parent.document.getElementById("id")


注:parent.document是window.parent.document的简写,有的时候jq的会获取不到父页面的元素,但是用js的可以(不要问为什么,我也不知道,只是工作时用的时候发现了,如果有人知道的,麻烦告知啦,谢谢)

猜你喜欢

转载自blog.csdn.net/weixin_41700532/article/details/80653517