We continue with our little jQuery Tips and Tricks school. In this article we'll show how to get HTML content of particular DOM element inside a HTML page.
Let's assume that there is the div with id "testdiv" and with content as follows:
<div id="testdiv">
This is content inside testdiv.
</div>
The next jQuery code will obtain the html code for particular element, in this case for div "testdiv"
// Code gets HTML content of
$(document).ready(function() {
alert($('#testdiv').html());
});
- Advertisement -
- Advertisement -