JavaScript Select Option Value Or Change Value

JavaScript selects an option value from any drop-down list. We can use it the change the selected option by using JavaScript and get the value of any specific item.

Select selectedIndex property is used to get the particular option value. selectedIndex property returns an indexed option value from the dropdown list.

HTML

<select id="selectSkill">
    <option value="HTML">HTML</option>
    <option value="CSS">CSS</option>
    <option value="Bootstrap">Bootstrap</option>
    <option value="jQuery">jQuery</option>
    <option value="JavaScript">JavaScript</option>
</select>

CSS

/*-- Just for the style of Input box--*/
select#selectSkill {
    width: 80%;
    padding: 4px 10px;
    height: 50px;
    border: 2px solid #ddd;
    border-radius: 6px;
    margin: 70px auto;
    display: block;
    font-size: 20px;
    background-color: #FAFAFA;
}
#selectSkill option{
    font-size: 18px

JavaScript

// Select option by change the selectedIndex value
var select = document.getElementById("selectSkill");
select.options.selectedIndex = 3;