0

我试图这样做,但结果为零:

    $(".fancybox-html").fancybox({
    type                : 'iframe',
    beforeLoad: function() {
        this.title = '<li onclick="parent.sendIframeDataToParent(document.getElementsByName(&quot;sector&quot;), &quot;sector_hook&quot;);">Submit</li>'
    }
});

这是 iframe 中输入的代码:

<input type="checkbox" id="contact" name="sector" value="cellular">

我错过了什么?

4

1 回答 1

0

尝试这个:

$(".fancybox-html").fancybox({
      type : 'iframe',
      beforeShow : function(){
      contactChecked = $('.fancybox-iframe').contents().find('#contact').is(':checked');
    },
      afterClose: function(){
      //   The checkbox state is now available in the parent to do with as you wish
      alert(contactChecked); 
    }
});

注意:这仅适用于 Fancybox2。

于 2012-12-07T11:47:19.430 回答