How to get all the ids of elements inside a list using jquery <p>I've a list as</p> <pre><code>&lt;ul id="list"&gt; &lt;li id="one"&gt;&lt;/li&gt; &lt;li id="two"&gt;&lt;/li&gt; &lt;li id="three"&gt;&lt;/li&gt; ..... .... .... &lt;/ul&gt; </code></pre> <p>I want to get the <code>ids</code> of every <code>li</code> element inside the <code>ul#list</code>. Since the number of <code>li</code> item is unknown, I would want to go through a loop for as long as an <code>li</code> item exist. Something like</p> <pre><code>while($('#list li') exists){ //Get id of the element } </code></pre> <p>Can anyone help me with this?</p>