jQuery ListBox single or multiple selected item(s)
<p>I got an ASP.NET ListBox, and on change I need to display the (single or multiple) selected text(s) in (single or multiple) alert(s). The number of alerts should be equal to the number of items selected. I tried the following code, where I am getting an extra alert showing the first item in the ListBox. Where did I go wrong?</p>

<pre><code>&lt;asp:ListBox ID="ListBox1" runat="server" Width="100px"
    SelectionMode="Multiple"&gt;
    &lt;asp:ListItem Selected="True" Value="1"&gt;White&lt;/asp:ListItem&gt;
    &lt;asp:ListItem Selected="False" Value="2"&gt; Silver &lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="3"&gt; Dark Gray &lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="4"&gt; Khaki &lt;/asp:ListItem&gt;
    &lt;asp:ListItem Value="5"&gt; Dark Khaki &lt;/asp:ListItem&gt;
&lt;/asp:ListBox&gt;

$(document).ready(function () {
    $("#ListBox1 ").change(function () {
        $("option").each(function () { 
            if (this.selected) {
                alert(this.text);
            }
        });
    });
});
</code></pre>

<p>Please help.</p>

<p>Thanks. </p>
