I've got a floated element (float:left
) width approximately 500px
of space on the right Is there a way, to find out how much space is available via jQuery? I want to do this dynamically and would love a jQuery way.
So I want to insert an element and let it be as big as there开发者_StackOverflow is space available.
Is your content inserted in a fixed-width container? If so, just calculate the exact width of your left-floated element and subtract it from the width of the container.
If it's not a fixed-width container, calculate that width first.
Example:
<div>
<span style="float:left;">a</span>
</div>
The resulting width, for your third element:
var availWidth = $('div').width() - $('span').width(); //Use proper selectors here
精彩评论