I know this question has been answered many times. However, my code does not seem to work despite I literally got it from the internet. I probably do something wrong, but what exactly I could not figure out.
I put the following JS code inside the HTML <head> tag :
$(document).ready(function() {
var imwidth = $('#jspp').width();
var imheight = $('#jspp').height();
if (imwidth < imheight) {
$('#jspp').width(100);
} else {
$('#jspp').height(100);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div>
<img id="jspp" src="https://placehold.it/300x300">
</div>
</body>
Does somebody have an idea of what could be wrong?
Thanks in advance!