I have HTML code
<select id="city">
<option value="A">Mumbai</option>
<option value="B">Bangalore</option>
<option value="C">Delhi</option>
<option value="D">Indore</option>
</select>
I want a JavaScript for getting the innerHTML
of option by its value.
I have tried
var selectedValue = document.getElementById('city').value;
var city = document.querySelector('#city option[value='+selectedValue+']').innerHTML;
alert(city);
But giving the error
SyntaxError: An invalid or illegal string was specified