I understand so far that in Jquery, with html() function, we can convert HTML into text, for example,
$("#myDiv").html(result);
var temp;
temp = html(result);
" <p>abc</p> "
$(#mydiv).html(result)
"abc"
<p>
"abc"
var temp=$(#mydiv).text()
No, the html
method doesn't turn HTML code into text, it turns HTML code into DOM elements. The browser will parse the HTML code and create elements from it.
You don't have to put the HTML code into the page to have it parsed into elements, you can do that in an independent element:
var d = $('<div>').html(result);
Now you have a jQuery object that contains a div
element that has the elements from the parsed HTML code as children. Or:
var d = $(result);
Now you have a jQuery object that contains the elements from the parsed HTML code.