JQuery-UI resizable, resize children

I have div elements containing images. I want to make a resizable div using jQuery-UI by resizing div and children image elements.

I tried using Resize as well, as shown below, but it seems to resize the first image divs instead of the corresponding child image.

$('div').resizable({
    alsoResize: $(this).find('img'),
    aspectRatio: true,
    maxHeight: 140
});

I created a fiddle to demonstrate this http://jsfiddle.net/letsgojuno/EhyGy/

It seems that this context is always the first div, not the resizing of the div.

+3
source share
1 answer

$(this) alsoResize div, , , . , :

$('div').each(function () {
    $(this).resizable({
        alsoResize: $(this).find('img'),
        aspectRatio: true,
        maxHeight: 140
    });

});
+5

Source: https://habr.com/ru/post/1795244/


All Articles