Thursday, January 31, 2013

Clear Items of a DropDownList using jQuery

<asp:DropDownList ID="ddlPeople" runat="server">
</asp:DropDownList>
 
$("select[id$=ddlPeople] > option").remove();
 
 
“> option” matches all child elements. Because each item in the drop down list is rendered as an <option> tag, you need to clear the child <option> tags in order to clear the items in a drop down list.

ref
 

No comments:

Post a Comment