Open In App

How to create a div element in jQuery ?

Last Updated : 17 Jul, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
There are various method to create HTML element inside an HTML document using JQuery. But the simplest of all is append() and prepend() method. Method 1: Using prepend() Method: The prepend() method is used to insert a specified content at the beginning of the selected element. Example: This example uses prepend() method to create div element at the beginning of selected element. html
<!DOCTYPE html>
<html>
    
<head>
    <title>Create div element</title>
    
    <script src=" 
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
    </script> 
    
    <!-- Script to add div element in the HTML document -->
    <script>
        $(document).ready(function() </