Reputation: 93
I am trying to append an input box at runtime with value as "�" using jQuery, but the value gets displayed as �. The below code works fine in Internet Explorer.
$('body').html($('<input id="myInput" type="text" value="�"/>'));
Upvotes: 2
Views: 627
Reputation: 388316
I think when you are using .html() the content is considered to be HTML encoded, so try
$('body').html($('<input />', {
id: "myInput",
type: "text",
value: ""
}));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Demo: Fiddle (it looks like the code snippet also does the same, so here goes the fiddle.)
Upvotes: 3