Answers for "how to select dropdown item based on value in jquery"

3

how to get the value of dropdown in jquery

BY LOVE
$('#ddlName option:selected').val();
Posted by: Guest on May-08-2020
-1

How to select selected on an option based on its value using jQuery

<div class="form-group">
    <label for="unit-department">Unit / Department</label>
    <select class="form-control" id="unit-department" name="unit-department" required="required">
        <option value="">...</option>
        @foreach ($unitDepartment as $item)
        <option value="{{ $item->kode_unit }}">{{ $item->nama }}</option>
        @endforeach
    </select>
</div>

<script>
$(document).ready(function(){
  $("#unit-department > option[value='HRD']").attr("selected","selected");
});
</script>

// Application of coding using laravel

<script>
$(document).ready(function(){
  $("#unit-department > option[value='HRD']").attr("selected","selected");
});
</script>
Posted by: Guest on October-24-2021

Code answers related to "how to select dropdown item based on value in jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language