How to select ubuntu from the following drop down box
<select><option value=""></option>
<option value="" selected="selected">Select Image</option>
<option value="3f2cb990-cd0e-4bfa-a23e-54701498a2e5" data-volume_size="2">ubuntu-12.04-server-cloudimg-amd64 (1.4 GB)</option>
</select>
I tried the following still this doesnt work
$('#id_image_id').find('option:contains("Ubuntu"):contains("12.04")').prop('selected',true) || $('#id_image_id').find('option:contains("ubuntu"):contains("12.04")').prop('selected',true);
Try this:
$("select").val("3f2cb990-cd0e-4bfa-a23e-54701498a2e5");
or
$('select option[value="3f2cb990-cd0e-4bfa-a23e-54701498a2e5"]').attr('selected','selected');
To get By text: that contains ubuntu
$('select').find('option:contains("ubuntu")').prop('selected', true);
To get that contents ubuntu as well as 12.04
$('select').find('option:contains("ubuntu"):contains("12.04")').prop('selected', true);