I need a way to scale image to width of window below is the code I currently wrote - any suggestions. Height should automatically adjust to width thus maintaining inherent ratio of image.
If i change the CSS do i even need to set height since it will automatically resize to set Width and maintain ratio?
<body>
<script>
window.onload = resizeImage;
(function($){
$(window).enllax();
});
function resizeImage(){
var w = window.innerWidth
var images = document.getElementsByClassName("main");
for(var i = 0; i < images.length; i++)
{
images(i).item.style.maxWidth = w;
}
</script>
<img class="main" src="images/bangkok.jpg">
</body>