0

I wanted to write a JavaScript (jQuery)-Function to read out the width of each child and childrens-childs to get the maxWidth of all child (and childrens-childs) from a i.e. div-element.

here my code so far:

function setBodyMinWidth(name){
var max = 0;
$(name).find('*').each(fucntion(){
    var width = $(this).outerWidth(true);
    if (width > max){
        max = width;
    }
});
$("body").css("minWidth", max+"px");

but it seems not to work. My problem is, that in my website my float: "right";-content is over the pagecontent if the browsers-wndow is to small. my page is under construction online, if u need some source-code, feel free to have a look here.

Sebastian Röher
  • 417
  • 7
  • 20

1 Answers1

0

js fiddle

markup:

<body>
    <div class=one >content1</div>
    <div class=two >content2</div>
</body>

css

.one {width: 50px;}
.two {width: 70px;}

js

var max = 0;
$('body').find('div').each(function(){
    var width = $(this).outerWidth(true);
    if (width > max){
        max = width;
    };
});
alert(max);
$("body").css("minWidth", max+"px");
Omar
  • 116
  • 1
  • 3
  • 10