resizing image

by Simplybj

HTML

<div class="hello" style="width:100%">
  <img src="https://cdn.pixabay.com/photo/2017/05/31/18/38/sea-2361247_960_720.jpg" style="width:50%">
</div>

JavaScript

$(function() {

  $(window).resize(function() {
    resizeImage();
  });

  function resizeImage() {

    var width = $('.hello').width();
    $('img').css('width': width / 2);
  }

});