I'm grabbing various jquery objects to put into an array and later spit out as HTML.
I'm trying to convert the jQuery object to a text string so it can be spit out as HTML later.
I'm using this technique at the moment:
console.log($myObject.clone().wrap('
However, that only appears to be grabbing the contents of my object.
For example, if $myObject is
My Title
the above only returns 'My Title' (no H2 tags).I've also trying using .text() but get the same result.
Is there a way to convert the entire jQuery object into a text string?
解决方案
Well, answering my own question.
console.log($('
').append($myObject.clone()).remove().html());
Thanks goes to John Feminella in this thread:
who references this post: