JSFiddle - React, Tailwind, and code Playground

by NinjaFish

HTML

<iframe></iframe>
<button>Click</button>

CSS

iframe {
    width: 400px;
    height: 300px;
}

JavaScript

(function($) {
    $(document).ready(function() {
        $("button").on("click", function() {
            var width = $("iframe").width();
            var height = $("iframe").height();
            
            $("iframe").width(height);
            $("iframe").height(width);
        });
        
        checkIframeSize();
    });
    
    function checkIframeSize() {
        console.log($("iframe").width() + ", " + $("iframe").height());
        window.setTimeout(checkIframeSize, 1000);
    }
})(jQuery);