By default, .css('max-width') will return "none" if max-width not defined, so the following job should complete the job:
if ($(this).css('max-width') !== 'none') { ... }
If you need to check only the inline style, which means that you are overriding the original CSS max-width property (for example, from a stylesheet file), you can do the following:
if (this.style.maxWidth !== '') { ... }
... as pure maxWidth style property will be empty "" if the CSS property has not been set.
source share