Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  49] [ 1]  / answers: 1 / hits: 17154  / 8 Years ago, thu, april 28, 2016, 12:00:00

So I'm trying to get the width of the element using jQuery.





alert($(#theList li:eq(0)).offsetWidth);

<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>

<ol id=theList>
<li>The quick brown fox
</ol>




More From » jquery

 Answers
3

jQuery has $(elem).width() function that returns offsetWidth of element





alert($(#theList li:eq(0)).width());

<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>

<ol id=theList>
<li>The quick brown fox</li> <!--also you forgot closing tag -->
</ol>




[#62375] Monday, April 25, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maya

Total Points: 418
Total Questions: 116
Total Answers: 112

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
;