4

I have div which have 600px width and 631px height initially .

There is two input field where user can change width and height . Inside this div i have an image

so the structure

<div class="container-div">
 <img src="img.jpg" class="new-img">
</div>

so when user resize the div size , image also need to be resize proportionally. It will not be stretched .

How i can do this ?

Note : i wrote the code for to resize the div after user entering their width and height . so i actually try to get code after div resize .

$(".input1, .input2").on("change",function(){
   measurement_change();
});


function measurement_change(){
 after calculation i set new_width and new_height 
 $(".container-div").css("width", new_width);
 $(".container-div").css("height", new_height);

   After this i hav e to resize image propotionally 

}

Please check.

Abilash Erikson
  • 341
  • 4
  • 26
  • 55

1 Answers1

1
$(".input1, .input2").on("change",function(){
   var width = $('.input1').val();
   var height = $('.input2').val();
   $(".container-div").css("width", width);
   $(".container-div").css("height", height);
   $(".new-img").css("max-width",width);
});
mahi
  • 59
  • 3