Reputation: 725
I have a ul. Within the ul there are x number of li. Within the li there is a single image.
That is:
<ul>
<li>image</li>
<li>image</li>
<li>image</li>
</ul>
I would like to be able to get the total width of the ul. Is this possible?
Thanks in advance.
Upvotes: 1
Views: 4380
Reputation: 3210
I'd say
var internaWidth = $("ul").width();
// or
var widthIncludingPadding = $("ul").outerWidth();
// or
var widthIncludingMargin = $("ul").outerWidth(true);
Depending on what you need
Upvotes: 1
Reputation: 433
First of all you should give an id to ul then this code may solve the problem:
<ul id="myul">
<li>image</li>
<li>image</li>
<li>image</li>
</ul>
$(document).ready(function() {
var totalWidth = $("#myul").width();
});
Upvotes: 0