Format lost after putting text in div (IE) using jQuery
I came across the following problem.
I'm switching formatted text (programming code) between a pre and a text area, programmatically using jQuery. Since I'm using a syntax highlighter on the pre, I'm also putting a copy of the code in an invisible div to use it as a temporary store before moving the code back undistorted to the textarea.
It works beautifully everywhere except on any version of IE. Transferring the text out of the div (using .html() on jQuery) removes all sorts of formatting from IE. Any ideas or workarounds you know about are appreciated.
I feel that some sort of escaping is involved but don't know how or why.
I wrote this small piece of code to show you better what I mean. Try putting in text with spaces etc, in your code in IE and other browsers. It keeps the formatting (spaces and tabs etc) in Firefox but not in IE.
I finally managed to sort it. It was in fact related to escaping. Escaping the code before and unescaping afterwards helps solve the problem across the browsers including Internet Explorer. Here's the corrected version of my example snippet