I have a problem with select option in html select element via JQuery. Next code demonstrate my problem:
$('select[name="location"] option[value=' + 'mercedes mercedes' + ']').attr('selected', true);
And i have simple html code for select with option value - "mercedes mercedes". When I run my script - i got exception:
"Error: Syntax error, unrecognized expression: [value=mercedes mercedes] throw new Error( "Syntax error, unrecognized expression: " + msg );"
When I delete whitespace - all is ok. Maybe anyone know - how to fix it?
Put quotes around your option :
$('select[name="location"] option[value="' + 'mercedes mercedes' + '"]')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With