title: jQuery Scrollable Div for Mobile Websites
body: <p>I'm trying to create a jQuery plugin for a mobile website that turns a div container into a scrollable container.  I accomplish this by wrapping all the children that are inside the div container in another div container thats absolutely positioned.  Then I modify the top or left css styles of the inside div to simulate moving the text up and down or left and right.  I'm using touch event listeners to determine when to move the scrolling div.</p>
  
  <p>However, I'm having some trouble setting the width() of my inside scrolling div.  Here's a sample of the code:</p>
  
  <pre><code>myObj.ready(function(){
  myObj.css({ 'position' : 'relative', 'overflow' : 'hidden' }).wrapInner('&lt;div id="scrollCntr"&gt;');
  $('#scrollCntr').prepend("&lt;img src='scrollBar.png' id='scrollBar' class='horizontal'");
  $('#scrollCntr').height( myObj.height() );
  
  if ( config.width &lt;= 0 ) {
      $('#scrollCntr').children().each(function(){
          if ( $(this).css('display') == 'inline' || $(this).css('float') == 'left' || $(this).css('float') == 'right' ) {
              totalWidth += $(this).width();
  
              for( var i = 0; i &lt; boxProps.length; i++ )
                  if ( $(this).css(boxProps[i]) != "" )
                      totalWidth += parseInt( $(this).css(boxProps[i]).replace( /px/i, '' ).replace( /em/i, '' ).replace( /pt/i, '' ) );
          }
      });
  } else {
      totalWidth = config.width;
  }
  
  console.log( totalWidth );
  $('#scrollCntr').width( totalWidth );
  console.log( $('#scrollCntr').width() );
  </code></pre>
  
  <p>});</p>
  
  <p>In this case, config.width is set to 719 and myObj is the container div being scrolled.  I'm not really sure what the problem is.  I didn't have any problems with this in my demo, when my children elements where just images, but when I applied it to my mobile website, where the children elements where div boxes, its been having problems.  Perhaps the children elements aren't being loaded in time?  But that wouldn't explain why I can't set the scrolling div's width.  Its definately being loaded.  I have no idea what the problem is...</p>