How to Replace innerHTML of a Div using jQuery


Use the jQuery html() Method

You can simply use the jQuery html() method to replace innerHTML of a div or any other element.

The jQuery code in the following example will replace the innerHTML of a DIV element having id pageTitle with an HTML heading on click of the button. Let's try it out:

<!DOCTYPE html>
<html lang="en">
<title>jQuery Replace innerHTML of a Div</title>
<script src=""></script>
        $("#pageTitle").html("<h1>Hello, World!</h1>");
    <div id="pageTitle">
        <p><b>Click the following button to replace me.</b><p>
    <button type="button">Replace HTML</button>