w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Dynamic Width = Height with jQuery

I think your problem is the scope your accessing this.

Try updating your height80 function to this:

function height80() {
    $('[data-image="height80"]').each(function () {
        var width80 = $(this).width()*0.8;
        $(this).css({ 'height': width80, 'max-height': width80 });

Here's an updated fiddle:


© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.