Opened 13 years ago
Closed 13 years ago
#5429 closed bug (duplicate)
.text() and .html() are mangling values in incorrect ways in Internet Explorer
Reported by: | greg.hellings | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | IE | Cc: | |
Blocked by: | Blocking: |
Description
In an effort to clean up strings of characters which might contain HTML entity characters, I am running the strings through jQuery's .text() and .html() methods. However, doing so mangles newline characters in the text in IE. The following is a test case:
var pretext = "\r\nLine 1\r\n\r\nLine2\r\n\r\n--- Line 3 ---\r\n\r\nLine 4\r\n"; alert(pretext); var text = jQuery("#someid").text(pretext).html(); alert(text);
In Firefox and Chrome, the strings pretext and text display identically. In Internet Explorer, text displays with no new line characters. I have been unable to verify whether this is a different behavior of IE versus the other browsers or whether this is a jQuery quirk.
Duplicate of #3144.