如何从父级访问iframe中的DIV [英] How to Access a DIV inside a iframe from a Parent

查看:84
本文介绍了如何从父级访问iframe中的DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人可以提供帮助,但我正在尝试访问div id =mnuGrp,它位于来自document.ready()部分内的父窗口的子iframe(id =iframe2)内,但不确定如何访问此内容父母中的子div为了应用fadein和fadeout来电。

Hoping someone can assist but I am trying to access a div id="mnuGrp" that resides inside a child iframe(id="iframe2) from the parent window within the document.ready() section but unsure how to access this child div in the parent inorder to apply fadein and fadeout calls.

想要在以下电话中使用:

Want to be used within the following call:

$(' ???? ').click(function(){ etc

其中????是我在iframe中访问子div的方法。

where "????" is my means to access the child div within the iframe.

任何帮助都将不胜感激。

Any help would be appreciated.

谢谢。

推荐答案

因为你特意在jQuery上下文中询问:

Since you're asking in a jQuery context specifically:

$(document).ready( function(){
    $('#iframe2').contents().find('div#mnuGrp').fadeIn('slow');
    // or whichever effect you prefer
});

请注意,您可能会受到同源政策的约束。主页面和框架来源。

Note that you will likely be constrained by the Same Origin Policy with respect to the main page and the frame source.

这篇关于如何从父级访问iframe中的DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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