Skip to main content

Bug Tracker

Side navigation

#3904 closed bug (worksforme)

Opened January 17, 2009 07:36PM UTC

Closed June 20, 2010 07:32PM UTC

Last modified March 15, 2012 03:00PM UTC

$('<span> </span>') ie bug - jQuery 1.2.6 & 1.3 both

Reported by: MarionNewlevant Owned by:
Priority: minor Milestone: 1.3.1
Component: core Version: 1.3
Keywords: Cc:
Blocked by: Blocking:
Description

$('<span> </span>').contents().length is 1 in firefox and safari, 0 in ie (6 & 7).

(maybe hard to read: this is a span containing a single space)

I have a work-around: $('<span/>').text(' ').contents().length is 1 everywhere.

jQuery 1.2.6 & 1.3 both.

Attachments (0)
Change History (2)

Changed August 07, 2009 05:20PM UTC by dmethvin comment:1

component: unfilledcore

Changed June 20, 2010 07:32PM UTC by dmethvin comment:2

resolution: → worksforme
status: newclosed

That's actually the way contents() works:

http://api.jquery.com/contents/

As .html() mentions, browsers don't always treat white space the exact same way. That's outside the control of jQuery though.