欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JQuery操作iframe父頁面與子頁面的元素與方法(實(shí)例講解)

 更新時(shí)間:2013年11月20日 08:58:19   作者:  
這篇文章主要介紹了JQuery操作iframe父頁面與子頁面的元素與方法。需要的朋友可以過來參考下,希望對(duì)大家有所幫助

JQUERY IFRAME
下面簡單使用Jquery來操作iframe的一些記錄,這個(gè)使用純JS與可以實(shí)現(xiàn)。

第一、在iframe中查找父頁面元素的方法:
$('#id', window.parent.document)

第二、在父頁面中獲取iframe中的元素方法:
$(this).contents().find("#suggestBox")

第三、在iframe中調(diào)用父頁面中定義的方法和變量:
parent.method
parent.value

iframe里用jquery獲取父頁面body

iframe.html

復(fù)制代碼 代碼如下:

<html>
<script src='jquerymin.js'>
</script>
<body id='1'>
    <div>it is a iframe</div>
</body>   
<script>
    $(document).ready(
        function()
        {

        var c = $(window.parent.document.body) //麻煩的方法: var c = $($(window).eq(0)[0].parent.document).find('body'); ,忘了可以用前面的方法了

        alert(c.html());
        }
    );

</script>
</html>

相關(guān)文章

最新評(píng)論