How to create div dynamically using jQuery?

To create a div dynamically, use the html() method. You can try to run the following code to learn how to create a div dynamically on button click −


Live Demo

<!DOCTYPE html>
    <script src=""></script>
        $("body").html("<div>This is a new div.</div>");

  <button>Create a new div</button>

<p>This is demo text.</p>