Search code examples
jqueryhtmlinternet-explorer-10

stop jquery append removing line breaks


I have a div that looks like this

<div id='wrap'></div>

I want to .append()

<input value="a&#10;b">

but the value gets altered to

"ab" 

after the append. It seems to be doing this in IE only. What am I doing wrong?


Solution

  • It's not only in IE. &#10; - newline character in ASCII. If you want multiline field, try to use <textarea>. Otherwise you can use zero width space:

    <input value="a&&#8203#10;b">
    

    DEMO