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>