Basically, I'd like to keep an element size at a certain ratio with the height, say maintaining the same value or 50% as the width. The width is determined by the browser window size. Doing that in jQuery, I'd simply write something like use the following
$(window).resize(function() {
$element = $('.keep-ratio');
$element.css("height", $element.css("width"));
});
However, I was wondering if there was a more efficient way of doing this without using .resize(). The reason I'm asking is because I'm writing a plugin for myself that will be applied to all elements which I want to keep a certain aspect ratio. Ideally, the plugin will only change the css style of the element.