Found an issue when using .css('aspect-ratio', x); If x is a number, 'px' seems to be added, causing the attribute to not be set. Looks like 'aspectRatio' needs to be added to cssNumber definition. My current work-around is to convert x to a string, e.g. use .css('aspect-ratio', x+'');