I am creating a jQuery based slider. There is a “display window" div 960px and another div inside, which contains all the content. The content has a dynamic width, and I want to get this size so that the script slider knows exactly how far to scroll on each side.
After loading the content (only simple PHP requests that output HTML), for some reason, the div inside is saved when another div width is infected, and I get 960px content (even if the content takes up more space). I set the div to "inherit: none! Important", and in jQuery I am looking for a way to set the initial width, then reset and look for the full width of the div. How do you approach this?
var contentWidth = $('#content').width();
$('#content').css('width', contentWidth);
alert ("#content width is " + contentWidth);
source
share