jQuery - 获取 ul 内所有 li 的宽度
我有一个ul。 ul 内有 x 个 li。里内有一个图像。
那就是:
<ul>
<li>image</li>
<li>image</li>
<li>image</li>
</ul>
我希望能够获得ul的总宽度。这可能吗?
提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会说
取决于你需要什么
I'd say
Depending on what you need
首先你应该给 ul 一个 id 然后这段代码可以解决问题:
First of all you should give an id to ul then this code may solve the problem:
将为您提供 ul 元素的宽度。
Will get you the width of the ul element.