Skip to main content

Bug Tracker

Side navigation

#6572 closed bug (fixed)

Opened May 17, 2010 06:01AM UTC

Closed June 18, 2010 02:15AM UTC

bugs about $(..).html() & .text()

Reported by: roviury Owned by:
Priority: Milestone: 1.4.3
Component: attributes Version: 1.4.2
Keywords: html bug text Cc:
Blocked by: Blocking:

var obj=$('<span>1<b>2</b>3</span>')

1. obj.html(function(){return $(this).text()})

expected result:

the content in <span> should be changed from 1<b>2</b>3 to 123

real result:

the content become empty

(similar bugs in ".html/text(function(){return $(this).html/text()})")

2. obj.html('12&')

expected result:

the content will be "12&"

real result:

the content will be "12", the "&" disappeared.

Attachments (0)
Change History (1)

Changed June 18, 2010 02:15AM UTC by dmethvin comment:1

resolution: → fixed
status: newclosed

In the first case, I've clarified in the documentation that the content is emptied before jQuery calls your function. You can use the oldhtml argument to see what it was.

In the second case, a bare ampersand character shouldn't be used in HTML. Instead it should be encoded as