How to change height of iframe based on dynamic conent within the iframe?

后端 未结 5 1144
攒了一身酷
攒了一身酷 2021-02-03 15:07

I have an iframe that has dynamic content. If the answers specific questions, additional information displays (hidden div becomes visible). I\'d like the height of the iframe

5条回答
  •  旧巷少年郎
    2021-02-03 15:33

    Esailija's answer works fine, but this is nicer imo.

    $('#ifr').contents($(".toggle_div")).bind("change", function () {
        $("#ifr").height($("#ifr").contents().find("html").height());
    });
    

提交回复
热议问题