I see &in my text box, but only want &. I think this has something to do with how the browser interprets javascript .innerHTML. The text c &must go through the div. For some reason, I cannot directly assign a value to the text field.
HTML code
<div id='div'></div>
<input id='textbox' type='text' />
Javascript Code
var str = 'this & char';
$('#div').append("<div>" + str + "</div>");
$('#textbox').val($('#div').html());
Actual HTML output
<div>this & char</div>
and the user sees this & charin the text box.
Desire HTML code output
<div>this & char</div>
and the user sees this & charin the text box.
source
share