Get code examples like "how to add selected attribute to option using javascript" instantly right from your google search results with the Grepper Chrome Extension. How to add custom attribute to select options? Sometimes can be usefull to add some data-attribute to the option tags of a select field in your django admin forms. The content between the opening tags is what the browsers will display in a drop-down list. The HTML option label Attribute is used to specify the text value which represents the shorted label for option. The SELECT element contains one or more OPTGROUP or OPTION elements to provide a menu of choices for the user. I need the “Indonesia” option to have selected="selected" attribute so when I click reset button, it will select “Indonesia” again. ), apply this syntax: Stack Exchange Network. However, the value of the value attribute is what will be sent to the server when a form is submitted.. We can control which value is selected by using selected attribute: Moreover, we can specify that an option isn't selectable by using the disabled attribute: By default, the web browser will render a list with the first option preselected. Add Option To Select Drop Down. We can also use 'selected' attribute in