EDIT: I am using Firefox 3.1+ specifically, as this is an intranet application.
I have the following html:
<em id="work-resize">re-size: from <span id="work-resize-from">3</span> to <span id="work-resize-to">5</span></em>
Using jQuery I want to get the following string:
're-size: from 3 to 5'
I assumed that using .text() would do exactly that, however:
$('#work-resize').text();
returns:
're-size: from <span id="work-resize-from">3</span> to <span id="work-resize-to">5</span>'
I peaked around, and I couldn’t find out why. I could use a function as suggested here remove tags which javascript returns with the text, but I really thought that the point of .text() was to strip out the tags, so it seems redundant to use my own function. Does anyone out there have a better solution, or suggestion if I am doing something wrong?
Are you sure? I just checked it, and the return value you’re describing sounds a lot like
.html():