问题
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