I understand so far that in Jquery, with html() function, we can convert HTML into text, for example,
$("#myDiv").html(result);
converts "result" (which is the html code) into normal text and display it in myDiv.
Now, my question is, is there a way I can simply convert the html and put it into a variable?
for example:
var temp;
temp = html(result);
something like this, of course this does not work, but how can I put the converted into a variable without write it to the screen? Since I'm checking the converted in a loop, thought it's quite and waste of resource if keep writing it to the screen for every single loop.
Edit:
Sorry for the confusion, for example, if result is " <p>abc</p> "
then $(#mydiv).html(result)
makes mydiv display "abc"
, which "converts" html into normal text by removing the <p>
tags. So how can I put "abc"
into a variable without doing something like var temp=$(#mydiv).text()
?
abc
" then $(#mydiv).html(result) should make mydiv display "abc". which "converts" html into normal text by removing thetags. So how can I put "abc" into a variable without doing something like this: var temp=$(#mydiv).text();
– eastboundr Nov 28 '11 at 17:32` tags are not removed, they are parsed into a paragraph element. The element is put into the `mydiv` element, so it's actually the paragraph element that shows the text, not the `mydiv` element.
– Guffa Nov 28 '11 at 17:35