jquery set selected attribute on an option using like -
how can set ubuntu selected following select box tried following below
<select> <option value="val1">val 1</option> <option value="val2">val 2</option> <option value="val3">val 3</option> <option value="val3">ubuntu -12.04 amd......</option> </select> $('#image_id').find('option[text="ubuntu"]').attr('selected');
try,
$('#image_id').find('option:contains("ubuntu -12.04")').prop('selected',true);
so per new request can like,
$('#image_id').find('option:contains("ubuntu"):contains("-12.04")').prop('selected',true);
Comments
Post a Comment