jQuery get max width of child div's

后端 未结 3 1394
不知归路
不知归路 2020-12-05 00:42

I need to get the max width(just the one width) of the child div in the wrapper div element

3条回答
  •  清歌不尽
    2020-12-05 01:17

    I like this approach because it hits the sweet spot (IMHO) between core readability and shortness:

    var max_w = 0;
    $('#wrapper div.image').each(function() {
        max_w = Math.max(max_w, parseInt($(this).width()));
    })
    

    YMMV of course.

提交回复
热议问题