Q:

Select a DropDown by values with jquery

<select id="id_deals-1-deal_template" name="deals-1-deal_template">
 <option selected="selected" value="">---------</option>
 <option value="1" selected="selected">Pear</option>
 <option value="2">Apple</option>
 <option value="4">Melon</option>
</select>

In order to select Melon I have to do this:
$('#id_deals-1-deal_template>option:eq(3)').prop('selected', true);

But I would rather have to select the primary key that is 4 in this case.
Hence is it possible to select a dropdown by its value rather than sequence?

A:

Try using .val which can be a setter or getter based on the argument. Below is a setter..
$('#id_deals-1-deal_template').val(4);

