Reputation: 1405
I have a simple question - is it even possible to get element's HTML with styles from DOM? I don't need any jQuery object, just plain HTML with all styles.
I would use it in case were I have grid with different styles across rows and I would like to get that html and styles and sent it to server where I would use it in a mail body - programatically ofcourse.
Is there an elegant way to do that?
Tnx for answers
Upvotes: 0
Views: 321
Reputation: 1453
$.html() (with no arguments) does exactly this: http://api.jquery.com/html/
From the example on the page:
<p>
<b>Click</b> to change the <span id="tag">html</span>
</p>
<script>
$("p").click(function () {
var htmlStr = $(this).html();
$(this).text(htmlStr);
});
</script>
When the function is called, the contents of htmlStr is
<b>Click</b> to change the <span id="tag">html</span>
(as a string)
Upvotes: 3