how select dropdown js works code example Example: javascript select element in dropdown document.getElementById("stateSelect").selected = true;