Answer by William for jQuery get DOM element as string
How about$(selector).prop("outerHTML");
View ArticleAnswer by ThiagoPXP for jQuery get DOM element as string
Following on what @Blazemonger have answered, if you are going to send this html content to the server, it's worth to get rid of all unnecessary tags, white-spaces and line-breaks that don't add any...
View ArticleAnswer by Tarion for jQuery get DOM element as string
How about:var str = $(selector)[0]Maybe add a check that there is one element returned.
View ArticleAnswer by Blazemonger for jQuery get DOM element as string
An old trick:var selector = ":input[type=text]:first";var str = $(selector).clone().wrap('<div/>').parent().html();Update You don't need to worry about calling .parent() since you're working with...
View ArticleAnswer by John Hartsock for jQuery get DOM element as string
Use jQuery.html() by appending to a created element.$('<div/>').append($(":input[type=text]:first").clone()).html()Here is a fiddle providing an example: http://jsfiddle.net/Zwbmx/1/
View ArticlejQuery get DOM element as string
Say I have$(":input[type=text]:first")How do I get<input type="text" value="" size="28" maxlength="140" tabindex="1" placeholder="search" class="textbox" name="q" autocomplete="off">Assuming I...
View Article