$(document).ready(function(){ var lenght = ($('#inner-scroll1 > div').lenght) * 252; $('#inner-scroll1').width(lenght); }); 

It is necessary to calculate the total width of the internal div (one div is 252px wide) inside # inner-scroll1 and assign it to # inner-scroll1 itself

  • maybe give some more markup? and jsfiddle? - zb '
  • one
    but generally * lenght is spelled length; * the length property is the length of an array-like collection and is translated as length * ($('#inner-scroll1 > div').lenght) * 252; it is not clear that you wanted to achieve this. - zb '
  • Thank you, it's a typo. All right, I had to calculate the embedded divs and multiply them by the known width of the individual - 252. As a result, I get the total width, which I assign to the external element - Alexander Timofeev
  • @eicto what is there to understand? the number of DIV elements multiplied by 252 - the width of the element $ ('# inner-scroll1') is calculated depending on the number of other elements, apparently some kind of crutch - zippp

1 answer 1

typo in the length property

 $('#inner-scroll1 > div').lenght > $('#inner-scroll1 > div').length