jQuery 如何存取控制 iframe 中的element

Posted in :

如果要存取 iframe 中的元素的話,可以使用 .contents() 後再來 .find().

範例程式:

$("iframe.punch-present-iframe").each(function() {
    var $iframe = $(this), 
        $contents = $iframe.contents();
        $font_style_block = $contents.find('#MaxChangeFontCss');
        if($font_style_block.length==0) {
            // task-1
        } else {
            // task-2
        }
});

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *