Reputation: 57
how can I calculate the Size of all Listelements in one Row? I get only one Size. But what I need is that following. When I resize the Browserwindow and 4 Listelemts are in one Row, or 2 etc. I need always the Size from all Elements in one Row.
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="result"></span>
$('li').each(function() {
var widthE = $('li').width();
console.log(widthE);
});
Here is my fiddle: http://jsfiddle.net/v127zvy0/7/
Upvotes: 0
Views: 42
Reputation: 57
Ok, the Answer is quite easy.
The UL needs display:inline
The Fiddle: http://jsfiddle.net/v127zvy0/24/
Upvotes: 0
Reputation: 36703
Just do
$(window).resize(function() {
var widthOfRow = $("ul").width();
});
This will give you the width of ul
which is width of a row in this case.
Upvotes: 0
Reputation: 2394
Wouldn't the width of the UL be the width of a row?
$(window).resize(function() {
var rowWidth = $('ul').width();
console.log(rowWidth);
});
Upvotes: 1