Getting and Setting HTML Content - J Query

You need to get or set a chunk of HTML content in the current web page.


jQuery provides the html() method for getting and setting chunks (or DOM structures) of HTML elements. In the following code, we use this method to set and then get the HTML value of the <p>element found in the HTML document:

Running this code in a browser will result in a browser alerting the HTML content contained within the <p>element, which we set using the html() method and then retrieved using the html() method.

This method uses the DOM inner HTML property to get and set chunks of HTML. You should also be aware that html() is not available on XML documents (although it will work for XHTML documents).

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

J Query Topics