Skip to main content

Bug Tracker

Side navigation

#11046 closed bug (wontfix)

Opened December 16, 2011 07:58PM UTC

Closed December 16, 2011 08:06PM UTC

Last modified December 16, 2011 10:29PM UTC

.text() property strips whitespace on IE 8

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

The following snippet:

$('<h1><div>sub</div> title</h1>').text();

Correctly returns: "sub title" on Chrome, FireFox and IE9.

But on IE 8 it returns: "subtitle"

Attachments (0)
Change History (3)

Changed December 16, 2011 08:01PM UTC by comment:1

jsFiddle example:

Changed December 16, 2011 08:06PM UTC by rwaldron comment:2

resolution: → wontfix
status: newclosed

Unlike the .html() method, .text() can be used in both XML and HTML documents. The result of the .text() method is a string containing the combined text of all matched elements. (Due to variations in the HTML parsers in different browsers, the text returned may vary in newlines and other white space.) Consider the following HTML

Changed December 16, 2011 10:29PM UTC by dmethvin comment:3

Just so you know it isn't jQuery doing the mangling:

IE8 and lower in particular likes to do strange things with whitespace.