html - how can i set width to image automatically using jquery? -


i'm in process of doing modal photo gallery. make things work out well, need set height or width 100% depends on whether 1 length bigger other. adding class contains height set working, small problem width. doesn't work this! help

here jquery

    $(function() {     if($('.modal-img').height() > $('.modal-img').width()) {      $('.modal-img').addclass('set-height');     }       else if($('.modal-img').height() < $('.modal-img').width()) {       $('.modal-img').addclass('set-width');     }     else {        $('.modal-img').addclass('set-height');        $('.modal-img').addclass('set-width');     }     }); 

can help? please. not know if it's because set position: absolute these images, hope not.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -