Answers for "jquery find option in select by value"

-1

jquery select option by value

$('.id_100 option[value=val2]').attr('selected','selected');
Posted by: Guest on December-07-2020
0

jquery select option by value

$('.selDiv option[value="SEL1"]')
Posted by: Guest on November-03-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 "jquery find option in select by value"

Browse Popular Code Answers by Language