Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#11046 closed bug (wontfix)

.text() property strips whitespace on IE 8

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

Description

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"

Change History (3)

comment:1 Changed 8 years ago by ido@…

jsFiddle example: http://jsfiddle.net/Qebq5/

comment:2 Changed 8 years ago by Rick Waldron

Resolution: wontfix
Status: newclosed

http://api.jquery.com/text/

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

comment:3 Changed 8 years ago by dmethvin

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

http://jsfiddle.net/zXAph/

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

Note: See TracTickets for help on using tickets.