0

I have a HTML page with buttons and text. This page can be changed from French to English to Spanish. The special characters (é, è, à, etc...) are rendered in their HTML code (e.g., à is à).

When I assign special characters in a text input (type="text") the character are rendered correctly but when I assign these characters to an input button (type="button") value, it shows the raw code.

If I use the browsers Developer Tools (F12) to change a letter in the value it will refresh itself and interpret the character.

Is there something I'm missing ? Or is it just a bug ? I have tried to use the HTML name code and the Javascript character escape sequence also, but with no luck.

2
  • 3
    Where is the code ? Commented Jul 17, 2019 at 19:19
  • "when I assign these characters to a input button value" - are you doing that by JS or in the HTML source as an attribute? Commented Jul 17, 2019 at 19:22

1 Answer 1

3

You need to use Unicode in JS, not HTML character code. See example.

$('#one').val('à');
$('#two').val('\u00e0');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>&#224;</p>
<input id="one" type="button" value="a" />
<input id="two" type="button" value="a" />

Sign up to request clarification or add additional context in comments.

1 Comment

why are there different codes? Why not using only one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.