0
0

More than 1 year has passed since last update.

htmlタグの属性修正できない場合

Last updated at Posted at 2022-07-16

htmlタグの属性修正できない場合(親設定済み)、以下の例をとする
あず、既存属性を削除してから設定する。

                     $('iframe').each(function () {
                            $(this).removeAttr("height");
                        });

                        $("iframe").css({
                          'height': '550px',
                          'border': '2px solid'
                        });

●iframeの高さを自動的に調整してくれるスクリプト

(function (window, $) {
$(window).on("load", function () {
$('iframe.autoHeight').each(function () {
var D = $(this).get(0).contentWindow.document;
var innerHeight = Math.max(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
);
$(this).removeAttr("height").css('height', innerHeight + 'px');
});
});
})(window, jQuery);

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0