I want set a dropdown(select) to be change based on the value of the entries.
I have
$('#mySelect').val('ab').change();
// or
$('#mySelect').val('ab').trigger("change");
$('select#myselect option[value="ab"]').
You can select dropdown option value by name
// deom
jQuery("#option_id").find("option:contains('Monday')").each(function()
{
if( jQuery(this).text() == 'Monday' )
{
jQuery(this).attr("selected","selected");
}
});
In your case $("#mySelect").val("fg")
:)
$('#dropdownid').val('selectedvalue');
$('#dropdownid').val('selectedvalue');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id='dropdownid'>
<option value=''>- Please choose -</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='selectedvalue'>There we go!</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
</select>
$('#mySelect').val('fg');...........