Bug Tracker

Opened 13 years ago

Closed 13 years ago

#1386 closed bug (fixed)

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.

Change History (4)

comment:1 Changed 13 years ago by mrtwice99

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

comment:2 Changed 13 years ago by john

Component: ajaxcore
need: ReviewTest Case

comment:3 Changed 13 years ago by john

Owner: set to john

comment:4 Changed 13 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev [2421].

Note: See TracTickets for help on using tickets.