Reputation: 1970
I have a select
element. Some option
may contain accents, so to display them properly I've converted them to HTML entities.
<select id="someid">
<option>Select...</option>
<option>Option one</option>
<option>Option twò</option>
</select>
My goal is to select one of the given options with jQuery. If the chosen option doesn't contain accents, everything works fine.
$("#someid").val("Option one"); // works
But when I try to select an option containing accents, it fails.
$("#someid").val("Option twò"); // fails
Here's a fiddle showing the problem.
How can I select an option containing accents?
Upvotes: 3
Views: 445
Reputation: 337656
You need to use the actual character in the value in jQuery:
$("#someid").val("Option twò");
Upvotes: 3