Find element on site from a fancybox iframe

徘徊边缘 提交于 2019-12-22 10:32:01

问题


I'm trying to update a element on my site from a fancybox. In the fancybox i do a $.post() and get back html data that i want to populate in a div on my page. I open up a iframe window with html and this script below is in that iframe. It cant find it from the fancybox so anybody got idea or solution on how to reach a element thats not inside the fancybox iframe?

$('.add-to-cart').click(function () {
    var $this = $(this).closest('form');

    $.post($this.attr('action'), { quantity: $this.find('#quantity_id').val() }, function (data) {
        parent.$.fancybox.close();
        $('#container').html(data);
    }, 'html');

    return false;
});

回答1:


Try this:

$('#container', $(parent.document)).html(data);


来源:https://stackoverflow.com/questions/10797270/find-element-on-site-from-a-fancybox-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!