I'm building a select dropdown, with the following function:
$.each(data,function(key, value) {
$select.append('<option value=' + key + '>' + value + '</option>');
});
Here I copy a sample of my origin data:
231:"Building"
232:"Trusting"
234:"Engineering"
235:"(*)Monitoring"
236:"Managing"
When building it, I want to:
- Mark the option that begins with '(*)' as selected, so I need to conditionally add the attr 'selected' to the option.
- Remove the '(*)' from the value shown.
Thanks for your help!