Skip to main content

Bug Tracker

Side navigation

#1386 closed bug (fixed)

Opened July 10, 2007 07:17PM UTC

Closed July 20, 2007 07:41PM UTC

inconsistent .html() and .text()

Reported by: mrtwice99 Owned by: john
Priority: major Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:
Description

Discussion of this bug: http://groups.google.com/group/jquery-en/browse_thread/thread/9a7e4a989106f57b/b5bbedf927fab901?lnk=gst&q=rsyring&rnum=2#b5bbedf927fab901


Summary Follows


The docs say that .text() is similar to .html() except that all the html formatting gets stripped out. However, .text() does not operate the same way as .html() when given a number object instead of a string.

Live Example:

http://rcs-comp.com/code_examples/text_function_bug/

I have some code that has a three column table in it. When the user

updates some number values in one of the two columns, I have some JS

that sums those columns and updates the value in the third column with

that info. When updating the third column, which his a TD element, I

tried to use text() to do it:

var total = col1Total + col2Total;

$('#wi_medical_total').text(total);

However, that did not work because the text in the cell never seemed

to get updated. So, I I changed the code to use .html() instead

of .text() :

var total = col1Total + col2Total;

$('#wi_medical_total').html(total);

and it worked just fine. So, I did some more playing and came up with

this:

var total = 5 + 5 + 'p';

$('#wi_medical_total').text(total);

Which finally worked and changed the text correctly to "10p". FYI,

"p" was just a random character.

Attachments (0)
Change History (4)

Changed July 10, 2007 07:29PM UTC by mrtwice99 comment:1

Sorry, this shouldn't be in the Ajax component. It should be a 'core' issue I believe.

Changed July 15, 2007 02:03PM UTC by john comment:2

component: ajaxcore
need: ReviewTest Case

Changed July 20, 2007 03:29PM UTC by john comment:3

owner: → john

Changed July 20, 2007 07:41PM UTC by john comment:4

resolution: → fixed
status: newclosed

Fixed in SVN rev [2421].