jQuery get max width of child div's

后端 未结 3 1392
不知归路
不知归路 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:10

    A not-so-difficult example function to consider; not as elegant as cwolves, but probably easier to follow if you're a beginner.

    function getMaxChildWidth(sel) {
        max = 0;
        $(sel).children().each(function(){
            c_width = parseInt($(this).width());
            if (c_width > max) {
                max = c_width;
            }
        });
        return max;
    }
    

    http://jsfiddle.net/userdude/rMSuJ/1/

提交回复
热议问题