How do you convert a jQuery object into a string?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
new String(obj).Update
I wrote the original answer in 2009. As of 2014, most major browsers now support
outerHTMLas a native property (see, for example, Firefox and Internet Explorer), so you can do: