Opened 13 years ago
Closed 13 years ago
#6572 closed bug (fixed)
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: |
Description
var obj=$('<span>1<b>2</b>3</span>')
- 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()})")
- obj.html('12&')
expected result: the content will be "12&" real result: the content will be "12", the "&" disappeared.
Note: See
TracTickets for help on using
tickets.
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
&
.