Reputation: 182
I have an image tag, which I wish to resize in proportion using width() method after uploading an image as below;
$('img').imagesLoaded().done(function(){
tmp = $('#asd').width()*0.614;
$('img').width(tmp);
});
Problem is, the width of the element must be calculated with every upload, and the upload is repeatable. With the code above, starting from the second upload, the width is calculated from the width set by jQuery and not from the dimensions of the uploaded image.
I wish to "undo" or "reset" the width set by the width() method so it becomes dynamic by the uploaded image's dimensions. How do I do that?
Upvotes: 2
Views: 839
Reputation: 7056
Once everything is done then you can reset the width
property using this:
$("#asd").width("");
if you want pre-defined or dynamic values you can use something like this:
var tmp= 50;
$(this).width(tmp);
Upvotes: 3