The length property in a jQuery object or $("#emplist").length refers to the number of elements that the jQuery selector matched. So, if your selector was "div", $("div").length would be the number of div elements in your document. $("#id") doesn't return a single DOM element, it returns a jQuery collection, with one DOM element in it.
What WOULD work is: $("#emplist").get(0).length. ".get(0)" returns the first (0th) DOM element which, since there is only one element, will be your "#emplist" element. On Sep 25, 2:15 pm, Pete <[EMAIL PROTECTED]> wrote: > I don't have a lot of experience with javascript and jquery so this > question may have an obvious answer that I missed. > > I have a combo box in jquery that I need to get the number of list > items from. I used the following syntax to get the number of items in > the list (based on some searching I did): > > $('#emplist').length > > The length indicated is 1, even though I know there are many items in > the list. > > So I tried the "standard" way: > > document.getElementById("emplist").length > > The value here is 62 > > If I use Firebug to examine the $('#emplist') object, I see that under > the $('#emplist') object is a length property that is '1' but if I > inspect the object in Firebug I also see a "0" object listed > immediately below the $('#emplist') object and it has a length = 62. > So my question is, given that this "0" object has the correct value, > how do I reference that in my jquery ? Somehow $('#emplist').length > is wrong but I can't seem to figure out how to reference the correct > value that is listed under "0" in firebug. Any ideas? What am I doing > wrong in getting the number of items in the combobox? > > Thanks, > Pete