check if select has options jquery

The prop() method provides a way to get property values for jQuery 1.6 versions, while the attr() method retrieves the values of attributes. Related: Multiple Selections using jQuery Select2 Plug-in with Asp.Net. alert( $('#example option').length ) Clear the existing options in a select with jQuery. In the above code snippet click event handler has been attached to the HTML input button with ID demo.When the button is clicked we check whether the selectedIndex of the HTML SELECT Dropdown is 0 or -1. That way, only elements that actually have that attribute would be selected. View options. Get Selected Options from Multiple Select Box. It is just an example and it might help in some scenarios. Select a Default Value From the element, if the user is reluctant not to select … The HTML Button has been assigned a jQuery OnClick event handler. The Dropdown CheckList jQuery widget transforms a regular