javascript set select options

Q&A for Work. 54. Note: Integer number is used for Index at the value place. Note: If no option is selected, the selectedIndex property will return -1. Edit in JSFiddle. Improve this answer. Full Source Loop through all options in a … If no index is specified, the new option will be inserted at the end of the list How to change a drop down box with Javascript, because the next FCKEditor post will be doing just that. November 4, 2016. Share. Must be an option or optgroup element: index: Optional. Note: The value "-1" will deselect all options (if any). Set selected value. option: Required. To trigger the change event, you can call the .change() or .trigger("change") method after setting the value.. Alternatively, you can use the .prop() method to set the selectedIndex property which reflects the index of the selected