How do you get convert a JQuery object to string?
|
I assume you're asking for the full HTML string. If that's the case, something like this will do the trick:
This is explained in more depth here, but essentially you make a new node to wrap the item of interest, do the manipulations, remove it, and grab the HTML. If you're just after a string representation, then go with |
|||||||||||||||||||
|
With jQuery 1.6, this seems to be a more elegant solution:
|
|||||||||||||
|
Can you be a little more specific? If you're trying to get the html inside of a tag you can do something like this: Html snippet:
Jquery:
|
|||
The best way to find out what properties and methods are available to an HTML node (object) is to do something like:
From jQuery 1.6+ you can just use outerHTML to include the HTML tags in your string output:
|
|||||
|
Just use .get(0) to grab the native element, and get its outerHTML property:
|
|||
|
This seems to work fine for me:
|
|||||
|
if you want to serialize the whole object to string use json. |
|||||
|
No need to clone and add to the DOM to use .html(), you can do:
|
|||
|
jQuery up in here so ...
return all that html shtuff
|
||||
|
There's my implementation of dumpElement:
|
|||
|
It may be possible to use the
|
||||
|