option selected code example

Example 1: html option selected

<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
    <option value="volvo">Volvo</option>
    <option value="saab" selected>Saab</option>
</select>

Example 2: get selected option value

var conceptName = $('#aioConceptName').find(":selected").val();

Example 3: select dropdown default value

<select>
  <option value="" selected disabled hidden>Choose here</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
  <option value="4">Four</option>
  <option value="5">Five</option>
</select>

Example 4: jquery option selected

$('.selDiv option:eq(1)').prop('selected', true)

Example 5: html select option selected true

<option selected='selected' />

Example 6: option selected aotu value

$(document).ready(
    function(){
        var theValue = $('#myId').val();
        $('option[value=' + theValue + ']')
            .attr('selected',true);
    });