You will want $("#myList").size().

Create an array with the three sizes - like var mylistsizes = [ 3, 9, 7 ].

Then, loop over the array and set a variable to the current value. On each iteration, if the current iteration is greater than the held variable, reset the variable to the current iteration.

When the loop is done, your variable will contain the largest value.

-- Josh


----- Original Message ----- From: "rolfsf" <[EMAIL PROTECTED]>
To: <jquery-en@googlegroups.com>
Sent: Wednesday, October 24, 2007 11:25 AM
Subject: [jQuery] help - compare 3 lists, get the largest number of items...




I'm still learning the most basic javascript :-(

I have 3 lists. I want to know how many items are in the longest list (ie.
most <li>). Then, I want to multiply that number by 275

assuming <ul id="myList1" class="myList"> etc.

I know I can get the length of a list using $('#myList').length();

How do I compare 3 numbers and take the largest?

thanks for any help!

Rolf
--
View this message in context: http://www.nabble.com/help---compare-3-lists%2C-get-the-largest-number-of-items...-tf4685230s27240.html#a13388830 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


Reply via email to